socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Cleanup and unify access to request details

Open andrejleitner opened this issue 4 years ago • 3 comments

There are socket.request.headers, socket.conn.request.headers and socket.handshake.headers all referencing the same thing, so this is just a suggestion for a clearer interface around request data.

Socket.IO server version: 3.1.0

https://github.com/socketio/socket.io/blob/3.1.0/lib/socket.ts#L126 https://github.com/socketio/socket.io/blob/3.1.0/lib/socket.ts#L587-L589 https://github.com/socketio/socket.io/blob/3.1.0/lib/socket.ts#L596-L598

andrejleitner avatar Feb 04 '21 10:02 andrejleitner

I think the official way is the handshake object: socket.handshake.headers.

We can indeed remove the other references (which were added a long time ago), but that will be a breaking change. We could schedule it for v4, what do you think?

darrachequesne avatar Feb 04 '21 11:02 darrachequesne

To decide what is the official way is probably up to you, I just vote for cleaner interface. One way instead of three seems better to me ... also for users to understand. The next major version makes sense.

andrejleitner avatar Feb 15 '21 09:02 andrejleitner

5.0.0?

andrejleitner avatar Jun 20 '21 18:06 andrejleitner