0

I'm writing a python program to access an HTTPS web page using the httplib module, and am having trouble retrieving a message body from the URL. Here is my example code:

username = "user"
password = "pass"
auth = base64.encodestring("%s:%s" % (username, password))
headers = {"Authorization" : "Basic %s" % auth, "User-agent" : "Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0a2"}
conn = httplib.HTTPSConnection("beta.space-track.org")
conn.request("GET", "/basicspacedata/query/class/tle_latest/NORAD_CAT_ID/37793/ORDINAL/1/orderby/FILE%20desc/limit/1/format/tle", headers=headers)
response = conn.getresponse()
data = response.read()
print response.status, response.reason
conn.close()

This returns an HTTP status of 204 No Content. Based on my knowledge, the 204 error means the request was understood fine, but no content was sent. What could be the problem? Am I authenticating wrong?

Jon Martin
  • 3,252
  • 5
  • 29
  • 45

0 Answers0