Hi Graham
This is the new filetest.wsgi modified using your instructions:
------------------------------------
import pprint
class LoggingMiddleware:
def __init__(self, application):
self.__application = application
def __call__(self, environ, start_response):
errors = environ['wsgi.errors']
pprint.pprint(('REQUEST', environ), stream=errors)
def _start_response(status, headers):
pprint.pprint(('RESPONSE', status, headers),
stream=errors)
return start_response(status, headers)
return self.__application(environ, _start_response)
def application(environ, start_response):
size=environ.get('QUERY_STRING')
if size=='': size='255'
size=int(size)
file=open('tmp/wsgitest','wb')
for i in range(size):
file.write('*')
file.close()
file=open('tmp/wsgitest','rb')
file_wrapper = environ.get('wsgi.file_wrapper', None)
start_response('200 OK',[])
return file_wrapper(file, 4096*16)
application = LoggingMiddleware(application)
--------------------------------------------------------
So now we can add an argumet to the url to ask a specified file size.
For example:
http://localhost:8001/test/?1024 will result in a 1024 file size.
Using this url we tested many sizes and it seems that it's ok for
sizes
in range 1-255 then it stop to work for sizes in ranges
256-7766 and then it works again for sizes greater than 7766.
So i think that it could be an hint for you.
Now i paste here the log for a good call and for a wrong one.
The good one:
Wed Feb 04 11:58:54 2009] [error] [client ::1] ('REQUEST',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] {'DOCUMENT_ROOT': '/
usr/local/apache2/htdocs',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'GATEWAY_INTERFACE':
'CGI/1.1',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'HTTP_ACCEPT': 'text/
html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'HTTP_ACCEPT_LANGUAGE': 'it-it,it;q=0.8,en-us;q=0.5,en;q=0.3',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'HTTP_CONNECTION':
'keep-alive',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'HTTP_HOST':
'localhost:8001',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'HTTP_KEEP_ALIVE':
'300',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'HTTP_USER_AGENT':
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:1.9.0.5) Gecko/
2008120121 Firefox/3.0.5',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'PATH': '/bin:/sbin:/
usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'PATH_INFO': '/',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'PATH_TRANSLATED': '/
usr/local/apache2/htdocs/index.html',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'QUERY_STRING':
'255',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'REMOTE_ADDR': '::
1',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'REMOTE_PORT':
'55956',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'REQUEST_METHOD':
'GET',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'REQUEST_URI': '/
test/?255',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SCRIPT_FILENAME': '/
Users/gpo/filetest.wsgi',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SCRIPT_NAME': '/
test',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_ADDR': '::
1',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_ADMIN':
'
giovanni...@softwell.it',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_NAME':
'localhost',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_PORT':
'8001',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_PROTOCOL':
'HTTP/1.1',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_SIGNATURE':
'',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'SERVER_SOFTWARE':
'Apache/2.2.11 (Unix) mod_python/3.3.1 Python/2.5.4 mod_wsgi/2.3',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.application_group': 'localhost:8001|/test',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.callable_object': 'application',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.listener_host': '',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.listener_port': '8001',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.process_group': '',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.reload_mechanism': '0',
[Wed Feb 04 11:58:54 2009] [error] [client ::1]
'mod_wsgi.script_reloading': '1',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.errors':
<mod_wsgi.Log object at 0x129d188>,
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.file_wrapper':
<built-in method file_wrapper of mod_wsgi.Adapter object at
0x134b458>,
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.input':
<mod_wsgi.Input object at 0x1369a70>,
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.multiprocess':
True,
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.multithread':
False,
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.run_once':
False,
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.url_scheme':
'http',
[Wed Feb 04 11:58:54 2009] [error] [client ::1] 'wsgi.version': (1,
0)})
[Wed Feb 04 11:58:54 2009] [error] [client ::1] ('RESPONSE', '200 OK',
[])
And now the wrong one:
[Wed Feb 04 12:00:02 2009] [error] [client ::1] ('REQUEST',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] {'DOCUMENT_ROOT': '/
usr/local/apache2/htdocs',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'GATEWAY_INTERFACE':
'CGI/1.1',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'HTTP_ACCEPT': 'text/
html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'HTTP_ACCEPT_LANGUAGE': 'it-it,it;q=0.8,en-us;q=0.5,en;q=0.3',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'HTTP_CONNECTION':
'keep-alive',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'HTTP_HOST':
'localhost:8001',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'HTTP_KEEP_ALIVE':
'300',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'HTTP_USER_AGENT':
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:1.9.0.5) Gecko/
2008120121 Firefox/3.0.5',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'PATH': '/bin:/sbin:/
usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'PATH_INFO': '/',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'PATH_TRANSLATED': '/
usr/local/apache2/htdocs/index.html',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'QUERY_STRING':
'257',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'REMOTE_ADDR': '::
1',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'REMOTE_PORT':
'55963',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'REQUEST_METHOD':
'GET',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'REQUEST_URI': '/
test/?257',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SCRIPT_FILENAME': '/
Users/gpo/filetest.wsgi',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SCRIPT_NAME': '/
test',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_ADDR': '::
1',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_ADMIN':
'
giovanni...@softwell.it',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_NAME':
'localhost',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_PORT':
'8001',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_PROTOCOL':
'HTTP/1.1',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_SIGNATURE':
'',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'SERVER_SOFTWARE':
'Apache/2.2.11 (Unix) mod_python/3.3.1 Python/2.5.4 mod_wsgi/2.3',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.application_group': 'localhost:8001|/test',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.callable_object': 'application',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.listener_host': '',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.listener_port': '8001',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.process_group': '',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.reload_mechanism': '0',
[Wed Feb 04 12:00:02 2009] [error] [client ::1]
'mod_wsgi.script_reloading': '1',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.errors':
<mod_wsgi.Log object at 0x129d188>,
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.file_wrapper':
<built-in method file_wrapper of mod_wsgi.Adapter object at
0x134b458>,
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.input':
<mod_wsgi.Input object at 0x1369a48>,
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.multiprocess':
True,
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.multithread':
False,
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.run_once':
False,
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.url_scheme':
'http',
[Wed Feb 04 12:00:02 2009] [error] [client ::1] 'wsgi.version': (1,
0)})
[Wed Feb 04 12:00:02 2009] [error] [client ::1] ('RESPONSE', '200 OK',
[])
And now http headers:
the good one :
http://localhost:8001/test/?255
GET /test/?255 HTTP/1.1
Host: localhost:8001
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:
1.9.0.5) Gecko/2008120121 Firefox/3.0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cache-Control: max-age=0
HTTP/1.x 200 OK
Date: Wed, 04 Feb 2009 11:03:42 GMT
Server: Apache/2.2.11 (Unix) mod_python/3.3.1 Python/2.5.4 mod_wsgi/
2.3
Content-Length: 255
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/plain
And the wrong one:
http://localhost:8001/test/?257
GET /test/?257 HTTP/1.1
Host: localhost:8001
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:
1.9.0.5) Gecko/2008120121 Firefox/3.0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 200 OK
I hope that these info can help to understand the problem.
We are using the embedded mode.
Thank you
G.
On Feb 4, 2:37 am, Graham Dumpleton <
graham.dumple...@gmail.com>
wrote:
> 2009/2/3 genro <
giovanni.porc...@gmail.com>:
> Can you wrap your WSGI application object if first code recipe in:
>
>
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Re...