goto-bus-stop / dart-event-source

W3C EventSource client implementation for Dart
MIT License
9 stars 12 forks source link

Support passing additional headers with request #14

Closed Olegas closed 4 years ago

Olegas commented 4 years ago

Sometimes additional headers is required to access event source, like cookies for authentication.

goto-bus-stop commented 4 years ago

Thanks for the PR! I tried to model the W3C EventSource API in this package, which does not support sending custom headers. I would prefer to keep it that way so that folks don't rely on custom headers on the server end, which would make the endpoint incompatible with browser event sourcing. W3C EventSource does support cookies, though; i wouldn't mind having a specific option for that. It would increase compatibility with browser event sourcing.

Currently you can create a custom HttpClient instance using the clientFactory option if you do need to specify headers. It's a bit more work but imho that's good: it discourages the non-spec thing by making it harder :)

Olegas commented 4 years ago

Thank you for feedback. Ok, so, let's close then.