Python Connecting To An Http Server
In my program, I am trying to access https://api.dropbox.com/1/oauth2/token. In order to do that, I was trying to use http.client.HTTPSConnection(). However, I am receiving a 400 s
Solution 1:
TL;DR: Change the lowercase 'get' to uppercase 'GET' should resolve the problem.
The reason: according to section 5.1.1, RFC2616:
The Method token indicates the method to be performed on the resource identified by the Request-URI. The method is case-sensitive.
RFC2616 also defined 8 methods which are "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", and "CONNECT". All of them are uppercase.
We do know some HTTP clients like python-requests
and jQuery.ajax
also support lowercase methods but they are just not the standard way defined by the RFC for using those methods. To prevent issues, use uppercase ones first.
Post a Comment for "Python Connecting To An Http Server"