devmonkZA / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

Complete Content-Length HTTP header for responses #83

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Testing WebIOPi with apigee console lead to errors that have to do with partly 
missing Content-Length header of HTTP responses.

This change fixes this.

http.py

    def sendResponse(self, code, body=None, contentType="text/plain"):
        if code >= 400:
            if body != None:
                self.send_error(code, body)
            else:
                self.send_error(code)
        else:
            self.send_response(code)
            self.send_header("Cache-Control", "no-cache")
            if body != None:
                self.send_header("Content-Type", contentType);
                encodedBody = body.encode();                           # Added Rgg
                self.send_header("Content-Length", len(encodedBody));  # Added Rgg
                self.end_headers();
                self.wfile.write(encodedBody)                          # Changed Rgg
        self.logRequest(code)

Maybe coap.py also needs this kind of change but I did not look at this one so 
far.

Andreas

Original issue reported on code.google.com by andreas....@googlemail.com on 9 Feb 2014 at 11:33

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1433.

Original comment by tro...@trouch.com on 21 Feb 2014 at 10:31