Shuhei Takahashi added the comment:
Hi karl,
Of course it is correct that the user agent is redirected to
http://example.com/bar#test when it got such response. However, it never means
UA can send an HTTP request containing fragment part.
In RFC7230 section 3.1.1, HTTP request line
New submission from Shuhei Takahashi:
When urllib.FancyURLopener encounters 302 redirection to a URL with fragments,
it sends wrong URL to servers.
For example, if we run:
urllib.urlopen('http://example.com/foo')
and the server responds like following.
HTTP/1.1 302 Found
Location: /bar