apache / pekko-http

The Streaming-first HTTP server/module of Apache Pekko
https://pekko.apache.org/
Apache License 2.0
148 stars 34 forks source link

Feature request: Provide an API to get file descriptor of the Socket connection #481

Open jliwork opened 5 months ago

jliwork commented 5 months ago

I have a specific use case. I’m using pekko server to handle REST APIs calls. I need to get the file descriptor associated with socket connection then pass it to some legacy C program.

I'd like to request an API to get the file descriptor associated with socket connection for GET/POST REST APIs calls.

pjfanning commented 5 months ago

I don't think it is a good idea for us to expose the internals of server sockets as file descriptors. Maybe someone else will have another view.

You might want to consider using another server tool that works at a lower level. You could take the requests on this other server and still use Pekko streams (or actors) if you want to continue to use Pekko for processing the requests.

raboof commented 5 months ago

I also suspect you might be better off with a lower-level API, but I'm pretty curious about your more exact use case :)

'Simply' passing the server socket to some other application will likely not work, as the connection is 'managed' by Pekko HTTP: for HTTP/1 it might do pipelining or wrap the connection in HTTPS, for HTTP/2 it might even do multiplexing - if the C program would read or write from that filesystem that would all break.

I guess perhaps you could stream the entity data to/from the application though - is that what you'd want?