Skip to content

Commit

Permalink
Use CRLF instead of LF in headers (RFC2616)
Browse files Browse the repository at this point in the history
  • Loading branch information
VEINHORN committed Feb 25, 2016
1 parent c6f2165 commit f5612ef
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions simple-testing-server.py
Expand Up @@ -38,7 +38,7 @@ def do_GET(self):
#send headers:
self.send_header("Content-type", "application/json")
# send a blank line to end headers:
self.wfile.write("\n")
self.wfile.write("\r\n")

try:
output = open(FILE_PREFIX + "/" + self.path[1:] + ".json", 'r').read()
Expand All @@ -56,19 +56,19 @@ def do_POST(self):
response_code = int(self.path[1:])
except Exception:
response_code = 201

try:
self.send_response(response_code)
self.wfile.write('Content-Type: application/json\n')
self.wfile.write('Client: %s\n' % str(self.client_address))
self.wfile.write('User-agent: %s\n' % str(self.headers['user-agent']))
self.wfile.write('Path: %s\n' % self.path)
self.wfile.write('Content-Type: application/json\r\n')
self.wfile.write('Client: %s\r\n' % str(self.client_address))
self.wfile.write('User-agent: %s\r\n' % str(self.headers['user-agent']))
self.wfile.write('Path: %s\r\n' % self.path)

self.end_headers()


form = cgi.FieldStorage(
fp=self.rfile,
fp=self.rfile,
headers=self.headers,
environ={'REQUEST_METHOD':'POST',
'CONTENT_TYPE':self.headers['Content-Type'],
Expand All @@ -84,7 +84,7 @@ def do_POST(self):
first_key=False
self.wfile.write('"%s":"%s"' % (field, form[field].value))
self.wfile.write('\n}')

except Exception as e:
self.send_response(500)

Expand Down

0 comments on commit f5612ef

Please sign in to comment.