william-os4y / fapws3

Fast Asynchronous Python Web Server (based on libev)
GNU General Public License v2.0
341 stars 38 forks source link

Response headers are spoiled #42

Closed blokhin closed 7 years ago

blokhin commented 7 years ago

The last version of fapws3, event backend is poll. Sometimes, very unexpectedly, instead of the usual 302 respond like this:

HTTP/1.0 302 FOUND
Content-Length: 539
Access-Control-Max-Age: 21600
Server: ...

I observe this:

   /1.0 302 FOUND
Content-Length: 539
Access-Control-Max-Age: 21600
Server: ...

Note the first four symbols are spoiled. Probably, it might be related to the use of threading module in my server, but this is just a guess.

blokhin commented 7 years ago

Cf. also #1

william-os4y commented 7 years ago

Could you explain what your code is doing ? what type of data do you return ? Could you provide a small code allowing me to reproduce the problem ?

william-os4y commented 7 years ago

The line you mention is build by line 111 at base.py and it's transformed at line 334 in mainloop.c Finally the line is send back to the client on line 509 at mainloop.c.

blokhin commented 7 years ago

@william-os4y thanks for posting. I'll try to isolate the code and share it here.

william-os4y commented 7 years ago

I cannot reproduce the problem. This is maybe linked to the bad memory allocation in fapws. On which OS did you compile it ? I'm running OpenBSD 6.1.

blokhin commented 7 years ago

This happened at my development environment in Windows 8.1 / Cygwin, may be that's the problem?

william-os4y commented 7 years ago

Could you retry your tests with the last changes proposed by vincent delft ? On my Openbsd machine those changes work perfectly. Indeed, now we have a better management of the memory zone allocated to the response_header. This should improve, maybe solve, your problem. Thanks to let us know.