Python connecting to an HTTP server
<p>In my program, I am trying to access <code>https://api.dropbox.com/1/oauth2/token</code>. In order to do that, I was trying to use <code>http.client.HTTPSConnection()</code>. However, I am receiving a 400 statement from the server, even though when I send the same request through my browser, I get an actual response:</p>

<p><code>{"error": "Call requires one of the following methods: POST, OPTIONS. Got GET."}</code></p>

<p>I believe that this happens for subdomains, since I also tested the function for <code>https://docs.python.org/3/</code>, and the result is very similar.</p>

<p>Here is my code (Python3):</p>

<pre><code>conn = http.client.HTTPSConnection('docs.python.org')
conn.request('get', '/3/')
response = conn.getresponse().read()
print(response)
</code></pre>

<p>How should I use the <code>http.client</code> library to send the proper request?</p>

<p>TL;DR: Change the lowercase 'get' to uppercase 'GET' should resolve the problem.</p>

<p>The reason: according to section 5.1.1, <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.txt" rel="nofollow">RFC2616</a>:</p>

<blockquote>
  <p>The Method token indicates the method to be performed on the
  resource identified by the Request-URI. The method is case-sensitive.</p>
</blockquote>

<p>RFC2616 also defined 8 methods which are "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", and "CONNECT". All of them are uppercase.</p>

<p>We do know some HTTP clients like <code>python-requests</code> and <code>jQuery.ajax</code> 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.</p>

python http dropbox