Why does wsgiref.simple_server report content-type of request as 'text/plain' while none was sent?

StackOverflow https://stackoverflow.com/questions/5924166

Pergunta

Output from client.py is text/plain although no content-type header was sent to the server.
Why?

# ---------------------------------------------- server.py
from wsgiref.simple_server import make_server

def simple_app(environ, start_response):
    print environ.get('CONTENT_TYPE')
    start_response('200 OK', [])
    return []

make_server('localhost', 88, simple_app).serve_forever()

# ---------------------------------------------- client.py
import subprocess
import urllib2

p = subprocess.Popen(['python', '-u', 'server.py'])
req = urllib2.Request('http://localhost:88', headers={})
assert not req.has_header('content-type')
urllib2.urlopen(req).read()
p.terminate()

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top