Skip to content

Instantly share code, notes, and snippets.

@tilgovi
Created September 6, 2014 01:47
Show Gist options
  • Save tilgovi/9021a996bdaf21595f12 to your computer and use it in GitHub Desktop.
Save tilgovi/9021a996bdaf21595f12 to your computer and use it in GitHub Desktop.
Testing FIN and RST behavior in gunicorn
# Log localhost port 8000 in the background
sudo tcpdump -i lo tcp port 8000 > log.txt &
# Send 5 megabytes upload
head -c5M /dev/urandom | curl -v -XPOST -d@- localhost:8000
# End the tcpdump and cat the log file
fg
^C
cat log.txt
# Should see a line with flags [F.] as the last line or second to last (before [R.])
# -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
#
# Example code from Eventlet sources
import os
import pprint
from wsgiref.validate import validator
import sys
from gunicorn import __version__
#@validator
def app(environ, start_response):
"""Simplest possible application object"""
errors = environ['wsgi.errors']
# pprint.pprint(('ENVIRON', environ), stream=errors)
print(environ)
if environ['REQUEST_METHOD'].upper() != 'POST':
data = b'Hello, World!\n'
else:
pass
#data = environ['wsgi.input'].read()
status = '401 UNAUTHORIZED'
response_headers = [
('Content-type','text/plain'),
('Content-Length', '0'),
('X-Gunicorn-Version', __version__),
("Test", "test тест"),
]
start_response(status, response_headers)
return iter([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment