[issue46285] http/server.py wont respect its protocol_version

2022-01-09 Thread Hugo Almeida


Hugo Almeida  added the comment:

Hi, buddy, there is no problem if invoke the http.server.test function as its 
designed, I mean the function iteself is okay, thus http/server.py invoked it 
via the functools.partial wrapper (handler_class) only will case this issue, 
which technically ignored its protocol parameter's specify. User of 
http/server.py::test should specify a handler class directly.

If this is a bug, maybe it is about the usage/desire of `functools.partial` ... 
I am not sure, closure model programming (the lambda etc.) is not eary for me 
and I closed this issue by courtesy yesterday, if reopen this issue will 
help/valueable a bit, please tell me.

Improve my English seems too nessary, thank you so much for your warm hearted.

--

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-09 Thread Éric Araujo

Éric Araujo  added the comment:

I am a bit confused!

The script you attached is to show a problem, but you’re saying there is no 
problem?

--

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-08 Thread Hugo Almeida


Hugo Almeida  added the comment:

The short story is, everything is okay,
its my bad to taken the test function out of context,
sorry about that of issue report.

# just for details review (related file attached):
#
# check line 1277 to line 1278 (main branch of Python currently):
# https://github.com/python/cpython/blob/17b16e1/Lib/http/server.py#L1277-L1278
#
# thus, `functools.partial` (closure/wrapper) will
# make the parameter `protocol` of the function `test` useless.
# So, specify a handler class directly.

--
resolution: remind -> not a bug
stage:  -> resolved
status: open -> closed
Added file: https://bugs.python.org/file50551/my_http.py

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-07 Thread Éric Araujo

Éric Araujo  added the comment:

I understand your report better after looking at the code.

There is indeed a protocol_version parameter in the test function (which is 
really a main function, not test), that sets the protocol attribute on the 
passed handler class.  (The class attribute is changed, which seems like a 
bug!)  The BaseHTTPRequestHandler class does have support for HTTP 1.1 (adds 
automatic keep-alive).

So if we ignore the distraction that OP changed the source code, and imaging 
instead that they called `test(protocol="HTTP/1.1")`, then there would be a bug 
if the requests went out as HTTP/1.0.

Hugo, can you attach a minimal reproducer?  (a python script as small as 
possible to show the problem — don’t edit code in http.server but call the 
http.server.test function with your own code)

--

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-07 Thread Éric Araujo

Éric Araujo  added the comment:

Hello and thanks for the report!

Could you tell more about what you’re trying to achieve?


Some notes:

You are not meant to change the code of provided modules, but to instantiate 
classes with the right parameters, or subclass in your own code to change how 
some methods work.

Supporting HTTP 1/1 is not just changing the protocol string, but also about 
supporting the actual behaviours defined in the 1.1 spec!

If the module has a parameter for version and it doesn’t work, then you can 
report a bug.  If there is no such parameter, you can open a feature request to 
ask for HTTP 1.1 support.

--
nosy: +eric.araujo

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-06 Thread Hugo Almeida


Hugo Almeida  added the comment:

update
==

It seems I've found the problem, http/server.py#L1277-L1288:

```
handler_class = partial(SimpleHTTPRequestHandler,
directory=args.directory)
```

Because of `partial` (provide by the functools module), there comes a closure 
like stuff ?

--
resolution:  -> remind

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-06 Thread Hugo Almeida


New submission from Hugo Almeida :

Hi,

Sorry for my poor English, this is not a spam issue.

How to reproduce


File about `http/server.py`, line 1235 at main branch.

1st, change `protocol_version`, e.g. from "HTTP/1.0" to "HTTP/1.1":
---  protocol="HTTP/1.0", port=8000, ...
+++  protocol="HTTP/1.1", port=8000, ...

2ed, run with `python -m http.server` and test by: `curl http://127.0.0.1:8000 
2>/dev/null| head -n 1`

Result
==

The response head line will always been a fixed HTTP Version refer to 
`BaseHTTPRequestHandler.protocol_version` defined, thus "HTTP/1.0 200 OK" 
currently.

Expected


It should equal to `http.server.test(protocol="...")` which specified like 
above, for this issue, it is expected to be "HTTP/1.1 200 OK".

P.S.


I know it is just locate in a test code area (http.servers::test), but what I 
submit here is about a Python Variable Scope issue maybe.

--
components: Library (Lib)
messages: 409894
nosy: openalmeida
priority: normal
severity: normal
status: open
title: http/server.py wont respect its protocol_version
type: enhancement
versions: Python 3.11

___
Python tracker 

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