pumazi/wsgi_intercept2 — Issue #6: 6 - urllib2.urlopen returns headers after content 
Author: pumazi
Created: 2011-12-22 19:25:11+00:00
State: open

What steps will reproduce the problem?

I'm using the following unittest:

import unittest
import urllib2

import wsgi_intercept
from wsgi_intercept.test_wsgi_app import create_fn
from wsgi_intercept.urllib2_intercept import install_opener

class TestAutocomplete(unittest.TestCase):

def setUp(self):
install_opener()
wsgi_intercept.add_wsgi_intercept('test_wsgi_intercept', 80, create_fn)

def test_wsgi_intercept(self):
print `urllib2.urlopen('http://test_wsgi_intercept/').read()`
assert False # Just so that nose doesn't hide the output.

if __name__ == '__main__':
unittest.main()

What is the expected output? What do you see instead?

Per the documentation, I expect for it to print 'WSGI intercept
successful!\n'. Instead, it shows 'WSGI intercept successful!\nHTTP/1.0
200 OK\nContent-type: text/plain\n\nWSGI intercept successful!\n'.

What version of the product are you using? On what operating system?

wsgi_intercept-0.3.1-py2.5.egg
Linux compakt 2.6.22-14-generic #1 SMP Tue Dec 18 08:02:57 UTC 2007 i686
GNU/Linux

Please provide any additional information below.

I can't figure out why it's tacking the headers onto the end of the
response. If I look at the code for create_fn, it looks correct.

Thanks,
-jj

Original link: http://code.google.com/p/wsgi-intercept/issues/detail?id=6