How to prevent python requests from percent encoding URLs contain semicolon?
<p>I want to post some data to a url like <code>http://www.google.com/;id=aaa</code><br>
I use follow codes:</p>

<pre><code>url = 'http://www.google.com/;id=aaa'
r = requests.post(url, headers=my_headers, data=my_data, timeout=10)
</code></pre>

<p>Unfortunately, I find <code>requests</code> just cut my uri to <code>http://www.google.com/</code> without any warning...    </p>

<p>Is there some way to pass the the parameters in their original form - without percent encoding?    </p>

<p>I try <code>config={'encode_uri': False}</code> but it was abandoned, and <code>urllib.unquote</code> wasn't useful as well.</p>

<p>Thanks!</p>

<p><a href="https://tools.ietf.org/html/rfc2616#section-3.2.2" rel="nofollow">RFC 2616, section 3.2.2</a> specifies the syntax of an HTTP URL as:</p>



<pre class="lang-none prettyprint-override"><code>http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]
</code></pre>

<p>It also says:</p>

<blockquote>
  <p>If the abs_path is not present in the URL, it MUST be given as "/" when
     used as a Request-URI for a resource</p>
</blockquote>

<p>In this URL:</p>

<pre class="lang-none prettyprint-override"><code>http://www.google.com;id=aaa
</code></pre>

<p>there is no <code>/</code>, so there is no <code>abs_path</code> and there is no <code>:</code>, so there is no <code>port</code>. It means that <code>www.google.com;id=aaa</code> is hostname.</p>

<p>Semicolons are not allowed in hostnames (see <a href="http://stackoverflow.com/a/3523068/389289">this answer</a> for what is allowed in hostname), so this <strong>URL is invalid</strong>.</p>

<p>This would be a valid URL, if <code>id=aaa</code> should be part of the path:</p>

<pre class="lang-none prettyprint-override"><code>http://www.google.com/;id=aaa
</code></pre>

<p>This also, if <code>id=aaa</code> should be part of the query:</p>

<pre class="lang-none prettyprint-override"><code>http://www.google.com/?;id=aaa
</code></pre>

<h1>EDIT</h1>

<p>The question has been modified to ask about <code>http://www.google.com/;id=aaa</code> instead.</p>

<p>That URL is valid, and as far as I was able to test it, <a href="/questions/tagged/python-requests" class="post-tag" title="show questions tagged &#39;python-requests&#39;" rel="tag">python-requests</a> handles it without any problems.</p>

python http python-requests