I am new to cURL and server sent events. I know how to build a simple GET, POST requests using cURL and getting response. Also, Theoretically I am aware that server sent eve
For completeness, your curl command should look something like this:
$ curl -N --http2 -H "Accept:text/event-stream" https://some.address.com/clocktimes
The -N
argument is very important, because curl buffers the response. So it's possible that your server will have sent some data, but it's not rendered on the screen because of curl buffering. Anytime you use curl for streaming, you should include this flag.
The -H
should be included as best practice because if your server has bound other protocols to the same port, it won't be able to disambiguate the protocol.
For example, if port 443 is used for HTTPS and SSE, then you will need to provide the -H
header so the server knows this is an SSE request.
The example above assumes the server is using HTTP/2. If not, drop the --http2
argument and change the scheme from https://
to http://