Sending a HTTP request using python -


i have intercepted http request using fiddler.

i send same request, time using python , not browser.

i did research , found httplib way go, reason code not work.

no request sent computer (i can verify using fiddler).

any ideas whats wrong ?

import httplib  headers = { "host":" unive.edu", "connection":" keep-alive", "content-length":" 5142", "cache-control":" max-age=0", "accept":" text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "origin":" http://unive.edu", "user-agent":" mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/34.0.1847.137 safari/537.36", "content-type":" application/x-www-form-urlencoded", "dnt":" 1", "referer":" http://unive.edu/webtixsnetglilot/selectcoursepage2.aspx?dtticks=635358672778578750&hidebackbutton=1", "accept-encoding":" gzip,deflate,sdch", "accept-language":" en-us,en;q=0.8,he;q=0.6", "cookie":" asp.net_sessionid=c5nch3ouzxkaaa5bk1rflaic; __atuvc=1%7c16%2c1%7c17%2c0%7c18%2c0%7c19%2c1%7c20; __utma=184162612.90089091.1384326557.1400242958.1400259831.35; __utmb=184162612.4.10.1400259831; __utmc=184162612; __utmz=184162612.1384326557.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ss#177904#2#1#stopload#635358666509203750=true; ss#177904#2#1#stopload#635358672778891250=true; hfskey=|||||||||gli; hfoikey=imvrnyvw; ss#177904#2#1#stopload#635358677931547500=true;" }  body = ""  conn = httplib.httpconnection("unive.edu") conn.request("post", "/web/selectcoursepage2.aspx?dtticks=635358682524828750&hidebackbutton=1", none, headers) res = conn.getresponse() 

thanks, michael.

the problem you've got content-length header claiming you're going send server 5142 bytes in post body you're not sending body content @ all. consequence, server hangs waiting body; fail time out in few minutes.

to fix this, ensure content-length header matches length of body in bytes.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -