aesteve / vertx-sse

Add support for Server-Sent-Events in Vert.x Web
Apache License 2.0
47 stars 13 forks source link

fix(SSEHandlerImp): shouldn't reject connection when no Accept header #12

Closed ctranxuan closed 6 years ago

ctranxuan commented 6 years ago

Hello, When a client tries to connect to the SSEHandler with no Accept header (eg via a curl), the connection is rejected with a 406. The spec (https://www.w3.org/TR/2015/REC-eventsource-20150203/#text-event-stream) says however:

For HTTP connections, the Accept header may be included; if included, it must contain only formats of event framing that are supported by the user agent (one of which must be text/event-stream, as described below).

So, in case there is no Accept header, the connection shouldn't be rejected.

The fix changes the condition of the SSEHandlerImpl to only reject connections when there is Accept headers that don't include "text/event-stream". If there is no Accept header, there is no rejection.

Note: the latest spec (https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) doesn't mention this anymore.

codecov-io commented 6 years ago

Codecov Report

Merging #12 into master will increase coverage by 0.54%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #12      +/-   ##
============================================
+ Coverage     89.18%   89.72%   +0.54%     
- Complexity       69       70       +1     
============================================
  Files            10       10              
  Lines           185      185              
  Branches         20       20              
============================================
+ Hits            165      166       +1     
  Misses           11       11              
+ Partials          9        8       -1
Impacted Files Coverage Δ Complexity Δ
...vertx/ext/web/handler/sse/impl/SSEHandlerImpl.java 100% <100%> (+3.44%) 9 <0> (+1) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d538992...da5afdf. Read the comment docs.

aesteve commented 6 years ago

Thanks a lot !