Problem with req.path_info
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Problem with req.path_info




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Problem with req.path_info  
Erik Demaine


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-05 10:46 PM

[As far as I can tell, this is the place to send bugs.
Apologies if this is not correct.]

Dear Developers,

I find that req.path_info is in some cases set to None instead of a string
such as ''.  My reading of the documentation suggests that req.path_info
should always be a string.

In particular, req.path_info being None causes a crash in cgihandler.
Lines 541--544 of mod_python/apache.py say

if len(req.path_info) > 0:
env["SCRIPT_NAME"] = req.uri[:-len(req.path_info)]
else:
env["SCRIPT_NAME"] = req.uri

which fails on the first line (the len call) if req.path_info is None.


Circumstance in which req.path_info is set to None:
Apache .htaccess includes
DirectoryIndex index.html index.py index.cgi
The script is called index.py.
The URI does not mention the script name, just the directory name, as in
http://www.foo.com/directory_containing_index.py/

(On the other hand, the URI
http://www.foo.com/directory_with_index.py/index.py
works fine, setting req.path_info to '' as it should.)


Let me know if you need further details.

Erik





[ Post a follow-up to this message ]



    Re: Problem with req.path_info  
Graham Dumpleton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-05 10:46 PM

Erik Demaine wrote ..
> [As far as I can tell, this is the place to send bugs.
>   Apologies if this is not correct.]
>
> Dear Developers,
>
> I find that req.path_info is in some cases set to None instead of a string
> such as ''.  My reading of the documentation suggests that req.path_info
> should always be a string.

Should read, will be string if set, otherwise None. There are a other
members of the request object which are similar, eg, req.finfo, where
the values can also be None as well as the indicated type.

In effect it just passes through what Apache sets it to, in the
circumstances you indicate, it is Apache that is leaving the value as a
null pointer and mod_python is simply propogating that.

> In particular, req.path_info being None causes a crash in cgihandler.
> Lines 541--544 of mod_python/apache.py say
>
>      if len(req.path_info) > 0:
>          env["SCRIPT_NAME"] = req.uri[:-len(req.path_info)]
>      else:
>          env["SCRIPT_NAME"] = req.uri
>
> which fails on the first line (the len call) if req.path_info is None.

Yes, it would appear that it needs fixing. Unless one of the developers
does it before you, you can log a bug report at:

http://issues.apache.org/jira/brows...N?report=select
[vbcol=seagreen]
> Circumstance in which req.path_info is set to None:
> Apache .htaccess includes
>      DirectoryIndex index.html index.py index.cgi
> The script is called index.py.
> The URI does not mention the script name, just the directory name, as in
>      http://www.foo.com/directory_containing_index.py/
>
> (On the other hand, the URI
>      http://www.foo.com/directory_with_index.py/index.py
> works fine, setting req.path_info to '' as it should.)
>
>
> Let me know if you need further details.
>
> Erik
> --
> Erik Demaine  |  edemaine@mit.edu  |  http://theory.csail.mit.edu/~edemaine/[/vbco
l]






[ Post a follow-up to this message ]



    Re: Problem with req.path_info  
Graham Dumpleton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-05 10:46 PM

Hmmm, I should check code first. This is already rectified in latest subvers
ion
copy of source code:

if req.path_info and len(req.path_info) > 0:
env["SCRIPT_NAME"] = req.uri[:-len(req.path_info)]
else:
env["SCRIPT_NAME"] = req.uri

No need to log a bug report. It will be fixed in 3. anyway.

Graham Dumpleton wrote ..[vbcol=seagreen]
> Erik Demaine wrote .. 
>
> Should read, will be string if set, otherwise None. There are a other
> members of the request object which are similar, eg, req.finfo, where
> the values can also be None as well as the indicated type.
>
> In effect it just passes through what Apache sets it to, in the
> circumstances you indicate, it is Apache that is leaving the value as a
> null pointer and mod_python is simply propogating that.
> 
>
> Yes, it would appear that it needs fixing. Unless one of the developers
> does it before you, you can log a bug report at:
>
>   http://issues.apache.org/jira/brows...N?report=select
> 
> in 






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:04 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register