Project

General

Profile

no access to headers from python

Added by jfeltz over 16 years ago

OS: Linux 2.6.26.2 (Debian etch)
version: lighttpd-1.4.19
python: 2.5.2

config:

server.port = 8000
server.document-root = "/usr/local/share/projects/code/cpp/netlib/http_integration_jf/libs/network/test/lighttpd_server/root"server.modules = ( 
"mod_accesslog","mod_expire","mod_usertrack","mod_cgi","mod_proxy","mod_secdownload","mod_userdir","mod_evhost","mod_status","mod_auth","mod_access","mod_cgi","mod_alias","mod_redirect","mod_rewrite")
mimetype.assign = ( ".png" => "image/png",".jpg" => "image/jpeg",".txt" => "text/plain",".htm" => "text/html",".html" => "text/html")
index-file.names = ( "index.htm" )
cgi.assign = ( ".py" => "/usr/bin/python" )

I am working on a custom c++ http client in which I am using lightttpd for unit
tests, my cgi script is as follows:

#!/usr/bin/python 
import cgi
import os, sys
import cgisupport

print os.environ

When prompting:
$telnet localhost 8000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /cgi-bin/echo_headers.py HTTP/1.0
Content-Length: 5
Content-Type: application/x-www-form-urlencoded
Host: localhost

test
HTTP/1.0 200 OK
Connection: close
Set-Cookie: TRACKID=51d0dca71ba035327acdfa4cbc7de55e; Path=/; Version=1
Content-type: text/plain; charset=us-ascii
Date: Wed, 07 Jan 2009 21:51:32 GMT
Server: lighttpd/1.4.19

{'CONTENT_LENGTH': '5', 'HTTP_CONTENT_LENGTH': '5', 'REMOTE_PORT': '60371', 'SERVER_NAME': 'localhost', 'GATEWAY_INTERFACE': 'CGI/1.1', 'SCRIPT_FILENAME': '/usr/local/share/projects/code/cpp/netlib/http_integration_jf/libs/network/test/lighttpd_server/root/cgi-bin/echo_headers.py', 'REDIRECT_STATUS': '200', 'REMOTE_ADDR': '127.0.0.1', 'SERVER_SOFTWARE': 'lighttpd/1.4.19', 'SCRIPT_NAME': '/cgi-bin/echo_headers.py', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'REQUEST_METHOD': 'POST', 'HTTP_HOST': 'localhost', 'SERVER_PORT': '8000', 'SERVER_PROTOCOL': 'HTTP/1.0', 'DOCUMENT_ROOT': '/usr/local/share/projects/code/cpp/netlib/http_integration_jf/libs/network/test/lighttpd_server/root', 'LD_LIBRARY_PATH': '/home/jpf/projects/code/cpp/local/lib/', 'SERVER_ADDR': '0.0.0.0', 'REQUEST_URI': '/cgi-bin/echo_headers.py'}
string length:
Connection closed by foreign host.

My problem is that this doesn't seem to provide a HTTP_ALL_HEADERS. How do I get
access to the user agent headers from within python?


Replies (3)

RE: no access to headers from python - Added by Olaf-van-der-Spek over 16 years ago

Sounds like a Python issue, not a Lighttpd issue...

RE: no access to headers from python - Added by icy over 16 years ago

You are not sending any user agent in your example and everything you do send, is there. Seems fine to me?

RE: no access to headers from python - Added by jfeltz over 16 years ago

Apologies. Yes, it would be helpful to actually send those. Tried that last night and a Arbitrary: header would show up as HTTP_ARBITRARY. Thanks.

    (1-3/3)