[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  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 

___
___
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  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 

___
___
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 

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