eventsource icon indicating copy to clipboard operation
eventsource copied to clipboard

Add `createConnection` option for http or https requests

Open xv2 opened this issue 6 years ago • 6 comments

Hi, I need a possibility of using createConnection option in the http/https request:

createConnection <Function> A function that produces a socket/stream to use for the request when the agent option is not used. This can be used to avoid creating a custom Agent class just to override the default createConnection function. See agent.createConnection() for more details. Any Duplex stream is a valid return value.

You can read more info about this function in the Node.js documentation: https://nodejs.org/api/http.html#http_http_request_options_callback

NOTE: The createConnection of globalAgent isn't suitable for me because I use other connections

P.S. Thanks for your work and the best library for EventSource.

xv2 avatar Mar 13 '19 16:03 xv2

Is this functionality in the spec? If not, why do you think we should deviate from the spec?

aslakhellesoy avatar Aug 20 '19 23:08 aslakhellesoy

Of course this option isn't in EventSource specification. This option (createConnection) is only for Node.js® as other your options (in your code): proxy, rejectUnauthorized ...

xv2 avatar Sep 01 '19 18:09 xv2

I suppose we could add it as a non-standard property on the eventSourceInitDict object. Any objections from anyone?

@xv2 send a pull request and we can discuss it.

aslakhellesoy avatar Sep 01 '19 20:09 aslakhellesoy

@aslakhellesoy PR: https://github.com/EventSource/eventsource/pull/120

xv2 avatar Sep 02 '19 07:09 xv2

This would be extremely helpful as there doesn't currently seem to be a way to use UNIX domain sockets with this library.

thedillonb avatar Sep 05 '19 18:09 thedillonb

Can we get a ruling on this?

thedillonb avatar Oct 02 '19 21:10 thedillonb