[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-02-14 Thread Éric Araujo

Éric Araujo  added the comment:

Thanks again!

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-02-14 Thread Mariatta


Mariatta  added the comment:


New changeset b27195332e91e932501f16cf9877761b218a9c99 by Miss Islington (bot) 
in branch '3.10':
bpo-46436: Fix command-line option -d/--directory in module http.server 
(GH-30701)
https://github.com/python/cpython/commit/b27195332e91e932501f16cf9877761b218a9c99


--

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-02-14 Thread Mariatta


Mariatta  added the comment:


New changeset 502ad3930ee8fcf76026edfc06a33621363cebea by Miss Islington (bot) 
in branch '3.9':
bpo-46436: Fix command-line option -d/--directory in module http.server 
(GH-30701) 
https://github.com/python/cpython/commit/502ad3930ee8fcf76026edfc06a33621363cebea


--
nosy: +Mariatta

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-02-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29286
pull_request: https://github.com/python/cpython/pull/31103

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-02-03 Thread miss-islington


Change by miss-islington :


--
keywords: +patch
pull_requests: +29285
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31102

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-02-03 Thread miss-islington

miss-islington  added the comment:


New changeset 2d080347d74078a55c47715d232d1ab8dc8cd603 by Géry Ogam in branch 
'main':
bpo-46436: Fix command-line option -d/--directory in module http.server 
(GH-30701)
https://github.com/python/cpython/commit/2d080347d74078a55c47715d232d1ab8dc8cd603


--
nosy: +miss-islington

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-01-23 Thread Géry

Géry  added the comment:

Thanks for mentioning this issue @merwok.

As you pointed out, function `test` in module 
[`http.server`](https://github.com/python/cpython/blob/main/Lib/http/server.py) 
expects a real request handler class argument (`SimpleHTTPRequestHandler` or 
`CGIHTTPRequestHandler`), not a partial object 
`partial(SimpleHTTPRequestHandler, directory=args.directory)` or 
`partial(CGIHTTPRequestHandler, directory=args.directory)`, so that the 
assignment of `protocol_version` class attribute in test is not ignored.

The partial object in the `if __name__ == '__main__'` branch of module 
`http.server` was introduced in the first place to pass the directory argument 
to the request handler class’s `__init__` method called in method 
`BaseServer.finish_request` of module 
[`socketserver`](https://github.com/python/cpython/blob/main/Lib/socketserver.py):

def finish_request(self, request, client_address):
"""Finish one request by instantiating RequestHandlerClass."""
self.RequestHandlerClass(request, client_address, self)

But `BaseServer.finish_request` is a factory method of `BaseServer` (the 
abstract creator) so it is *designed* to be overridden in subclasses to 
customize the instantiation of the request handler class `BaseRequestHandler` 
(the abstract product). So the proper way to instantiate 
`SimpleHTTPRequestHandler` and `CGIHTTPRequestHandler` with the `directory` 
argument is to override `BaseServer.finish_request`.

I have just updated my PR to implement this. It fixes both 
[#46285](https://bugs.python.org/issue46285) and 
[#46436](https://bugs.python.org/issue46436).

--

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-01-22 Thread Éric Araujo

Éric Araujo  added the comment:

The use of partial may cause bugs!

Here is reported that the `protocol` parameter (of the `test` function) is 
ignored because it’s set on the partial object instead of the handler class: 
https://bugs.python.org/issue46285

--
nosy: +eric.araujo

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-01-20 Thread Géry

Change by Géry :


--
versions: +Python 3.9

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-01-19 Thread Géry

Change by Géry :


--
nosy:  -docs@python

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-01-19 Thread Géry

New submission from Géry :

The API of [`http.server`](https://docs.python.org/3/library/http.server.html) 
supports the `directory` optional parameter for `CGIHTTPRequestHandler` (which 
is inherited from `SimpleHTTPRequestHandler`). The CLI of `http.server` 
supports the corresponding `-d/--directory` option.

The `-d/--directory` option is passed to `SimpleHTTPRequestHandler` as the 
`directory` argument:

> python -m http.server --directory /tmp/

But the `-d/--directory` option is not passed to `CGIHTTPRequestHandler` (which 
is enabled with the `--cgi` option):

> python -m http.server --directory /tmp/ --cgi

So the option is ignored in that case.

--
components: Library (Lib)
messages: 410973
nosy: docs@python, maggyero
priority: normal
pull_requests: 28899
severity: normal
status: open
title: Pass the -d/--directory command-line option to 
http.server.CGIHTTPRequestHandler
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

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