1

I have intercepted an HTTP request using FIDDLER.

I would like to send the same request, just this time using python and not my browser.

I did some research and found that httplib is the way to go, but for some reason my code does not work.

No request is sent from my computer (I can verify this by 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, like 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.

asked May 17, 2014 at 12:19

2 Answers 2

1

The problem is that you've got a Content-Length header claiming that you're going to send the server 5142 bytes in the POST body but you're not sending any body content at all. As a consequence, the server hangs waiting for the body; it will probably fail with a time out in a few minutes.

To fix this, ensure that the Content-Length header matches the length of the body in bytes.

answered May 17, 2014 at 14:02
Sign up to request clarification or add additional context in comments.

Comments

0

Please try print(res.status)

Otherwise what I'm using is: http://docs.python-requests.org/en/latest/

rekaszeru
19.2k7 gold badges62 silver badges73 bronze badges
answered May 17, 2014 at 12:27

1 Comment

Its actually stuck on "res = conn.getresponse()", it never gets to the command after it

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.