ERR_INVALID_HTTP_RESPONSE when requesting with axios on http server python

0

Hello, I have this simple server in python:

from http.server import BaseHTTPRequestHandler, HTTPServer

class S(BaseHTTPRequestHandler):
    def _set_headers(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/plain')
        self.send_header('Access-Control-Allow-Origin', '*')
        self.send_header('Access-Control-Allow-Methods', 'PUT, POST, DELETE, GET, OPTIONS')
        self.end_headers()

    def do_GET(self):
        self._set_headers()
        self.wfile.write('[]'.encode('utf-8'))


httpd = HTTPServer(('0.0.0.0', 5006), S)
print('Server opened in', httpd.server_address)
httpd.serve_forever()

But when I make a request with the axios

this.$axios.get('http://0.0.0.0:5006/users')
    .then(function (res) {
        self.users = res.data
    })

In the Chrome console it returns me the error ERR_INVALID_HTTP_RESPONSE

    
asked by anonymous 03.06.2018 / 21:49

0 answers