sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

Websockets server API doesn't work with firefox 74 #203

Open jakgra opened 4 years ago

jakgra commented 4 years ago

Hi. First thanks for the great library, I really like it :) .

When running examples/webapp.c I noticed it doesn't work with firefox 74. The assert on ws_attach_server() (line 101) fails. The problem lies in the ws.c file on line 254.

libdill checks if the "Connection" header equals "Upgrade", but firefox sends "keep-alive, Upgrade" not only "Upgrade" as chrome and others do. The websockets standard (https://tools.ietf.org/html/rfc6455#section-4.2) specifies that the Connection must include a case-insensitive Upgrade value. So firefox correctly follows the standard, but libdill in this case doesn't.

If you are interested I'm happy to create a PR to fix this.

For the PR I see 2 options: 1) follow the standard and check for substring and not equality 2) don't check at all. There seem to be some proxy servers in the wild that don't correctly forward hop by hop headers. So the server only receives Connection: keep-alive, and not the whole Connection: keep-alive, Upgrade. See https://stackoverflow.com/questions/50192812/firefox-combining-connection-keep-alive-upgrade-conflicts-with-mobile-operat . So to support a wider audience of clients this is also an interesting option in my opinion.

If you are interested in a PR please specify which of the above 2 options you would like me to implement. Thanks.

octetta commented 4 years ago

Thank you for debugging this issue and making notes. I just spent the weekend re-writing a crummy Python monitoring system with libdill and ran into the Firefox issue well into the project.