Recouse / EventSource

Server-sent events in Swift
MIT License
45 stars 10 forks source link

Receiving events without data #19

Open komkovla opened 4 days ago

komkovla commented 4 days ago

Description

dataTask stream would receive event with event only without any data when data is present. After investigation I found out that SessionDelegate would pass only part of data with event, separating response from the server to several didReceiveData calls. Sometimes SessionDelegate would pass full block, then processing of the message is correct.

To Reproduce

I am communicating with java-spring SSE server on localhost, I can share server with instructions to run it if needed

Steps:

Expected behavior

Library would cache data to the buffer and parse event only when complete event is received.

Steps:

Additional context

Thanks for taking your time to implement this library, integration was super easy. I can try to implement caching data myself and create a pull request.

Recouse commented 4 days ago

Could you please provide more details about the issue? If I understand correctly, the data from SessionDelegate is being split into chunks, which is causing the event to fail to parse correctly.

Feel free to create PRs as well, they are always welcome!

komkovla commented 3 days ago

Exactly! I will add example of this issue later