william-os4y / fapws3

Fast Asynchronous Python Web Server (based on libev)
GNU General Public License v2.0
341 stars 38 forks source link

PATH_INFO set by fapws3 differs from Python's wsgiref #24

Closed saffsd closed 12 years ago

saffsd commented 13 years ago

The PATH_INFO set by fapws3 does not prepend a leading '/', whereas wsgiref's simple_server does. This causes problems in places such as wsgiref.utils.shift_path_info, where an IndexError is raised due to lack of the leading slash.

PEP333 states that: PATH_INFO The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash.

So in this case it seems that wsgiref is at fault in not handling the empty string correctly.

I am basing my use of fapws3 from code on http://nichol.as/benchmark-of-python-web-servers

import fapws._evwsgi as evwsgi
from fapws import base
from pong import application

def start():
    evwsgi.start("0.0.0.0", 8080)
    evwsgi.set_base_module(base)

    evwsgi.wsgi_cb(("/", application))

    evwsgi.set_debug(0)
    evwsgi.run()

if __name__=="__main__":
    start()

Is there any particular reason that fapws3's behaviour differs from wsgiref? It seems that since wsgi_cb was called with '/' as the first argument, the PATH_INFO should reflect that.

william-os4y commented 13 years ago

Hello saffsd,

Thanks to look at Fapws. I'm not sure I understand well your concern ... Let me explain how Fapws deals with PATH_INFO.

First PATH_INFO is the remaining part of the URL.

Thus if you register "/", you will have the following results:

If you register "", the results will be:

If you register "/hello", the results will be:

If you register "/hello/", the results will be:

PATH_INFO is closely linked to the registered wsgi_cb.

Does this helps you ?

William

ps: Do not heasitate to join the mailing list for such questions/concerns.

william-os4y commented 12 years ago

no reaction ... sounds that my explanation helps