[issue525520] httplib/HTTPConnetion: wrong HOST header

2022-04-10 Thread admin


Change by admin :


--
github: None -> 36196

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue403232] Preserve Nonstandard Port Number in Host Header

2022-04-10 Thread admin


Change by admin :


--
github: None -> 33713

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-12-07 Thread iMath

iMath  added the comment:

Yes, I met with the same bug, see the post for description and bug 
investigation 
https://stackoverflow.com/questions/43185804/using-httphandler-cause-django-server-side-shows-http-400-and-invalid-http-host/47434323#47434323

--
nosy: +redstone-cold

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-11-19 Thread Vinay Sajip

Change by Vinay Sajip :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-11-19 Thread Vinay Sajip

Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment:


New changeset b071a5e838a0e84c4e8a60448fbd40e8a7e5c882 by Vinay Sajip (Miss 
Islington (bot)) in branch '3.6':
bpo-30904: Removed duplicated Host: header. (GH-4465) (#4468)
https://github.com/python/cpython/commit/b071a5e838a0e84c4e8a60448fbd40e8a7e5c882


--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-11-19 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4400

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-11-19 Thread Vinay Sajip

Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment:


New changeset e96ba183c43ad6633b5d014b3dc57433e2802faf by Vinay Sajip in branch 
'master':
bpo-30904: Removed duplicated Host: header. (#4465)
https://github.com/python/cpython/commit/e96ba183c43ad6633b5d014b3dc57433e2802faf


--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-11-19 Thread Vinay Sajip

Change by Vinay Sajip :


--
keywords: +patch
pull_requests: +4398
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-10-26 Thread Vinay Sajip

Change by Vinay Sajip :


--
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-10-26 Thread Berker Peksag

Change by Berker Peksag :


--
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30904] Python 3 logging HTTPHandler sends duplicate Host header

2017-07-11 Thread Leon Helwerda

New submission from Leon Helwerda:

The logging HTTPHandler sends two Host headers which confuses certain servers.

Tested versions:
Python 3.6.1
lighttpd/1.4.45

Steps to reproduce (MWE):

1) Set up a lighttpd server which is to act as the logging host (we do not 
actually implement anything that accepts the input here). Optionally enable the 
debug settings from https://redmine.lighttpd.net/projects/1/wiki/DebugVariables 
(specifically, add debug.log-condition-handling = "enable" to 
/etc/lighttpd/lighttpd.conf) to follow what is happening inside the server.
2) In python3:
import logging
import logging.handlers
handler = logging.handlers.HTTPHandler('localhost', '/')
logging.getLogger().setLevel(logging.INFO)
logging.getLogger().addHandler(handler)
logging.info('hello world')
3) Notice that the access logs in /var/log/lighttpd/access.log show a 400 
response for the request (in Python, the response is ignored). If the debugging 
from 1) is enabled, then /var/log/lighttpd/error.log contains a line "duplicate 
Host-header -> 400".

This is not a bug in lighttpd. The server adheres to RFC7320 (sec. 5.4, p. 44): 
"A server MUST respond with a 400 (Bad Request) status code [...] to any 
request message that contains more than one Host header field".

A workaround is to put the full URL in the second argument of HTTPRequest:
handler = logging.handlers.HTTPHandler('localhost', 'http://localhost/')
Then lighttpd follows RFC2616 (sec. 5.2, p. 37): "If Request-URI is an 
absoluteURI, the host is part of the Request-URI. Any Host header field value 
in the request MUST be ignored."

The origin of this issue is that the http.client.HTTPConnection.putrequest 
method (called by HTTPHandler.emit) already adds a Host header unless 
skip_host=True is given. Thus the manual addition of a Host header is duplicate.

Other versions like Python 2.7 might also be affected but I did not test.

--
components: Library (Lib)
messages: 298161
nosy: lhelwerd
priority: normal
severity: normal
status: open
title: Python 3 logging HTTPHandler sends duplicate Host header
type: behavior
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2017-01-26 Thread Jonathan Guthrie

Jonathan Guthrie added the comment:

Michael Sweet's draft RFC requiring that the scope should be included in the 
Host line expired in May 2014 and I can't find where it ever went anywhere.  
Does anyone have any updated information?

--
nosy: +JonathanGuthrie

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-26 Thread Jonathan Guthrie

Jonathan Guthrie added the comment:

Yes, it is more closely related to Issue 23448.  My search for related issues 
apparently wasn't exhaustive enough.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-25 Thread Martin Panter

Martin Panter added the comment:

More closely related: Issue 23448, about the same thing with urllib, which adds 
the Host value itself. Any solution should be shared between both modules.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2017-01-25 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-25 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-25 Thread Martin Panter

Changes by Martin Panter :


--
components: +Library (Lib)
stage:  -> needs patch
versions: +Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29375] httplib: wrong Host header when connecting to IPv6 link-local address

2017-01-25 Thread Jonathan Guthrie

New submission from Jonathan Guthrie:

This is related to issue 5111.

An IPv6 link-local address must include a scope specifier as part of the 
address passed to the HTTPConnection or HTTPSConnection constructor, that scope 
specifier is not being stripped from the address passed in the HTTP 1.1 Host: 
header line.

So, suppose I was attempting to connect to an HTTP server on 
fe80::8aae:1dff:fea4:29c8.  That's a link-local address, so I must give the 
scope specifier, which is the interface I can use to connect to that address.  
So, the address I would pass to the HTTPConnection constructor might look like 
"fe80::8aae:1dff:fea4:29c8%eth0".  The appropriate Host line in the HTTP 
request would be "Host: [fe80::8aae:1dff:fea4:29c8]" but it is actually "Host: 
[fe80::8aae:1dff:fea4:29c8%eth0]"

Compliant HTTP servers reject requests including this line as malformed.

--
messages: 286276
nosy: JonathanGuthrie
priority: normal
severity: normal
status: open
title: httplib: wrong Host header when connecting to IPv6 link-local address
type: behavior
versions: Python 2.7, Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29375>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2015-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3b6e0720a69d by Serhiy Storchaka in branch '2.7':
Issue #22095: Fixed HTTPConnection.set_tunnel with default port.  The port
https://hg.python.org/cpython/rev/3b6e0720a69d

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2015-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Backported to 2.7 because this is needed to support proxy with a port in 
urllib/urllib2 as documented. See issue24311.

--
versions: +Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2015-02-12 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy:  -demian.brecht

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23448
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2015-02-11 Thread Neil Gierman

New submission from Neil Gierman:

Using a scoped IPv6 address with urllib2 creates an invalid Host header that 
Apache will not accept.

IP = fe80:::::0001%eth0
req = urllib2.Request(http://[; + IP + ]/)
req.add_header('Content-Type', 'application/json')
res = urllib2.urlopen(req, json.dumps(data))

Apache will reject the above request because the Host header is 
[fe80:::::0001%eth0]. This behavior was reported to Apache at 
https://issues.apache.org/bugzilla/show_bug.cgi?id=35122 and the Apache devs 
will not fix this as there are new RFCs prohibiting scopes in the Host header. 
Firefox had the same issue and their fix was to strip out the scope from the 
Host header: https://bugzilla.mozilla.org/show_bug.cgi?id=464162 and 
http://hg.mozilla.org/mozilla-central/rev/bb80e727c531.

My suggestion is to change urllib2.py's do_request_ method from:

if not request.has_header('Host'):
request.add_unredirected_header('Host', sel_host)

to:

if not request.has_header('Host'):
request.add_unredirected_header('Host', re.compile(r%.*$).sub(, 
sel_host, 1))

I have not tested this patch to urllib2.py however I am now using similar logic 
in my code to override the Host header when I create my request:

IP = fe80:::::0001%eth0
req = urllib2.Request(http://[; + IP + ]/)
req.add_header('Host', '[' + re.compile(r%.*).sub(, IP, 1) + ']')
req.add_header('Content-Type', 'application/json')
res = urllib2.urlopen(req, json.dumps(data))

--
components: Library (Lib)
messages: 235762
nosy: ngierman
priority: normal
severity: normal
status: open
title: urllib2 needs to remove scope from IPv6 address when creating Host header
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23448
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2015-02-11 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +demian.brecht

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23448
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23448] urllib2 needs to remove scope from IPv6 address when creating Host header

2015-02-11 Thread Martin Panter

Martin Panter added the comment:

I’m no IPv6 expert, but there seems to be a few standards:

* https://tools.ietf.org/html/rfc6874 (Feb 2013). Encodes as 
http://[fe80::1%25eth0]/; says Windows uses this form. Also mentions the 
unencoded http://[fe80::1%eth0]/ form. Says that the HTTP Host header should 
not include the scope zone identifier, since it is not necessarily relevant to 
the server.

* https://tools.ietf.org/html/draft-sweet-uri-zoneid-01 (Nov 2013). Encodes 
as http://[v1.fe80::1+eth0]/; says CUPS uses this form. Also acknowledges the 
RFC %25 form. Says that the Host header _should_ include the scope, to help 
with servers that send back self-referencing absolute URLs.

Also, I would probably find IP.split('%', 1)[0] easier to read than a regular 
expression.

--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23448
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-12-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also comments on Rietveld (e-mail notification likely fell in spam).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-12-11 Thread Demian Brecht

Demian Brecht added the comment:

Thanks for the ping Serhiy, indeed the review notification email was sitting in 
spam. New patch addressing review comments as well as rectifying my own 
silliness.

--
Added file: http://bugs.python.org/file37419/issue22095_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-12-11 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berker.peksag

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-12-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 676d6bcfc031 by Serhiy Storchaka in branch '3.4':
Issue #22095: Fixed HTTPConnection.set_tunnel with default port.  The port
https://hg.python.org/cpython/rev/676d6bcfc031

New changeset ebe2072e5472 by Serhiy Storchaka in branch 'default':
Issue #22095: Fixed HTTPConnection.set_tunnel with default port.  The port
https://hg.python.org/cpython/rev/ebe2072e5472

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-12-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your contribution Demian.

--
resolution:  - fixed
stage: patch review - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-11-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-11-28 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


Added file: http://bugs.python.org/file37309/issue22095_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-11-28 Thread Demian Brecht

Demian Brecht added the comment:

Thanks Serhiy, new patch addresses your comments.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-11-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If call _get_hostport() in set_tunnel() then it should be removed in _tunnel().

As for tests, it would be better do not rely on implementation details. Instead 
you can monkey-patch the send() method of of HTTPConnection instance and check 
passed argument.

--
nosy: +nikratio, orsenthil, serhiy.storchaka
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-08-06 Thread Demian Brecht

Demian Brecht added the comment:

Bump for review

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-07-28 Thread Demian Brecht

New submission from Demian Brecht:

Creating this bug for clarity, but was encountered while investigating 22041 
(now set as not a bug).

When using set_tunnel with default port, the port value in the host header is 
set to None:

send: b'POST [PATH] HTTP/1.1\r\nHost: [HOST]:None\r\nAccept-Encoding: 
identity\r\nContent-Length: 41\r\nAccept: text/plain\r\nContent-type: 
application/x-www-form-urlencoded\r\n\r\n[FORM_DATA]'

This issue seems to have been introduced in 3.4 when _tunnel_host and 
_tunnel_port were introduced to decouple the destination host and port from the 
proxy host and port.

--
components: Library (Lib)
messages: 224175
nosy: demian.brecht
priority: normal
severity: normal
status: open
title: Use of set_tunnel with default port results in incorrect post value in 
host header
type: behavior
versions: Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22095] Use of set_tunnel with default port results in incorrect post value in host header

2014-07-28 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file36140/issue22095.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22095
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11227] [DOC] asyncore - use 'Host' header in HTTP example

2011-03-06 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Fixed in b630a135a86c.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11227] [DOC] asyncore - use 'Host' header in HTTP example

2011-02-23 Thread Sandro Tosi

Changes by Sandro Tosi sandro.t...@gmail.com:


--
assignee: sandro.tosi - docs@python
nosy: +docs@python

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11227] [DOC] asyncore - use 'Host' header in HTTP example

2011-02-16 Thread Sandro Tosi

New submission from Sandro Tosi sandro.t...@gmail.com:

Hi, following up 
http://mail.python.org/pipermail/docs/2011-February/003096.html I wrote a patch 
to introduce the 'Host' header in the HTTP example of asyncore doc. I've also 
fixed an indentation error with the last 2 lines of the same example (simple 
cutpaste would fail with unexpected intentantion).

Given it's a doc issue, and it quite easy, I think it should be backported to 
the current on-maintainence releases (the example fails on all of them).

--
assignee: sandro.tosi
components: Documentation
files: asyncore-use-host-header-py3k.patch
keywords: patch
messages: 128700
nosy: sandro.tosi
priority: low
severity: normal
stage: patch review
status: open
title: [DOC] asyncore - use 'Host' header in HTTP example
versions: Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file20774/asyncore-use-host-header-py3k.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11227] [DOC] asyncore - use 'Host' header in HTTP example

2011-02-16 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11227] [DOC] asyncore - use 'Host' header in HTTP example

2011-02-16 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

Patch looks fine to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2010-11-13 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

Fixed in r86450 (py3k). Will be back porting shortly.

--
resolution:  - fixed
stage:  - committed/rejected

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2010-11-13 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

r86461 (release31-maint)
r86462 (release27-maint)

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2010-10-18 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2010-10-18 Thread Senthil Kumaran

Changes by Senthil Kumaran orsent...@gmail.com:


--
assignee:  - orsenthil
nosy: +orsenthil

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2010-10-18 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo
versions:  -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Incorrect 'Host' header when using urllib2 to access a server by its IPv6 link-local address

2010-02-09 Thread slmnhq
I have a snippet of Python code that makes an HTTP GET request to an
Apache web server (v 2.2.3) using urllib2. The server responds with an
HTTP 400 error presumably because of a malformed 'Host' header.

The snippet is quite simple: it creates a url based on IPv6 string
literal syntax, then creates a Request object and calls urlopen.

def via_urllib2 (addr=fe80::207:b8ff:fedc:636b, scope_id=eth4):
host = [%s%%%s]:80 % (addr, scope_id) # [fe80::207:b8ff:fedc:
636b%eth4]
url = http://+host+/system/status/;
req = urllib2.Request(url)
f = urllib2.urlopen(req)
print f.read()

The urlopen() throws: HTTPError: HTTP Error 400: Bad Request

The Apache error_log reports Client sent malformed Host header.

Googling for apache Client sent malformed Host header ipv6 I came
across the following bug:

https://issues.apache.org/bugzilla/show_bug.cgi?id=35122

The problem is that Apache does not handle the scope id in the host
header field very well and reports a 400 error. So I tried to override
that field by creating my own header in the above snippet:

   ...
   req.add_header('Host', [+urllib.quote(addr)+])
   ...

Now the header is simply 'Host: [fe80::207:b8ff:fedc:636b] (notice
the lack of %eth4). However, this still results in the same error.

I know this is not a problem with urllib2 per say, but I'm posting
here in the hope that some Python coder may be knowledgeable enough
about HTTP and IPv6 that they might be able to provide an answer.

Thank you,

Salman
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-07-02 Thread chkneo

chkneo chk...@gmail.com added the comment:

As per the RFC 2732 host header should be wrapped with []. I am
attaching patch for this too which is applied on trunk(2.7)

--
keywords: +patch
nosy: +chkneo
type:  - behavior
Added file: http://bugs.python.org/file14424/5111.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-07-02 Thread chkneo

chkneo chk...@gmail.com added the comment:

RFC 2732 Section three have the following details.

  host  = hostname | IPv4address | IPv6reference
  ipv6reference = [ IPv6address ]

The patch contains check for : and adding the brackets

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-07-02 Thread chkneo

Changes by chkneo chk...@gmail.com:


Removed file: http://bugs.python.org/file14424/5111.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-07-02 Thread chkneo

Changes by chkneo chk...@gmail.com:


Added file: http://bugs.python.org/file14425/5111.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-07-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Thanks for the patch. It would be better if you also added a test to
Lib/test/test_httplib.py (unless for some reason it's technically
impossible to do so).

--
nosy: +pitrou
versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2 -Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-07-02 Thread chkneo

chkneo chk...@gmail.com added the comment:

Attaching the test patch

--
Added file: http://bugs.python.org/file14430/5311_test.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-03-31 Thread Derek Morr

Changes by Derek Morr derekm...@psu.edu:


--
nosy: +dmorr

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 loopback

2009-01-30 Thread Guillaume Desmottes

New submission from Guillaume Desmottes gdesm...@gnome.org:

To reproduce:
- Launch a HTTP server listening on an Inet6 socket on, say, port 
- Try to connect using the IPv6 loopback: 
http = httplib.HTTPConnection('[::1]:')
http.request('GET', '/foo')
r = http.getresponse()
print r.status
- You get 400 (bad-request) instead of 404

It seems that's because the HTTP request is wrong. Python sends this header:
Host: ::1:
but it should be:
Host: [::1]:

I'm using python 2.5.2-1ubuntu1 on Intrepid.

--
components: Library (Lib)
messages: 80827
nosy: gdesmott
severity: normal
status: open
title: httplib: wrong Host header when connecting to IPv6 loopback
versions: Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5111] httplib: wrong Host header when connecting to IPv6 litteral URL

2009-01-30 Thread Guillaume Desmottes

Guillaume Desmottes gdesm...@gnome.org added the comment:

Actually, this bug is present when you try to connect to any URL
containing an IP6 and a port.

So, we have the same problem when using, for example:
http = httplib.HTTPConnection('[2a01:8790:16d:0:218:de87:164:8745]:')

but
http = httplib.HTTPConnection('[2001:4860:0:1001::68]:80')

does work. Probably because we use the default HTTP port.

--
title: httplib: wrong Host header when connecting to IPv6 loopback - httplib: 
wrong Host header when connecting to IPv6 litteral URL

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5111
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Host: header

2008-04-13 Thread Penny Y.
Hello,

I have a problem with a request url,for example, I have the code below,

import httplib

try:
conn = httplib.HTTPConnection(192.168.1.1)
conn.request(GET, /)
r1 = conn.getresponse()
if r1.status == 200:
result = 0
except Exception:
result = -1


but the server on 192.168.1.1 accept virtual host request only.
That's to say, I need to specify a Host: header in the request.
How to do it? thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Host: header

2008-04-13 Thread Gabriel Genellina
En Mon, 14 Apr 2008 01:04:40 -0300, Penny Y. [EMAIL PROTECTED] escribió:

 I have a problem with a request url,for example, I have the code below,

 import httplib

 try:
 conn = httplib.HTTPConnection(192.168.1.1)
 conn.request(GET, /)
 r1 = conn.getresponse()
 if r1.status == 200:
 result = 0
 except Exception:
 result = -1


 but the server on 192.168.1.1 accept virtual host request only.
 That's to say, I need to specify a Host: header in the request.
 How to do it? thanks.

Add a `headers` parameter to the request method.
See http://docs.python.org/lib/httpconnection-objects.html
Something like this (untested):

  headers = {'Host', 'the.host.name'}
  conn = httplib.HTTPConnection(192.168.1.1)
  conn.request(GET, /, headers=headers)

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list