WebSocket-for-Python icon indicating copy to clipboard operation
WebSocket-for-Python copied to clipboard

Add ability to set custom Origin header

Open rdbhost opened this issue 10 years ago • 4 comments

It is sometimes useful to be able to set a custom Origin header.

There is a 'headers' parameter to the client constructor (threaded client), where you can provide a new Origin header, but it is appended to the headers which already have an Origin value. Servers ignore duplicate Origin values.

I suggest changing the header code to allow the default Origin header to be overwritten by an Origin entry in the headers parameter.

Also, in the absence of an over-riding Origin header, the default should be schema://host[:port] per rfc 6454, not the full url.

I can provide a patch if you wish.

rdbhost avatar Dec 12 '14 05:12 rdbhost

Hi David,

Thanks for the patch. I've commented it but it looks good and will probably be merged.

Cheers,

2014-12-12 6:57 GMT+01:00 David Keeney [email protected]:

It is sometimes useful to be able to set a custom Origin header.

There is a 'headers' parameter to the client constructor (threaded client), where you can provide a new Origin header, but it is appended to the headers which already have an Origin value. Servers ignore duplicate Origin values.

I suggest changing the header code to allow the default Origin header to be overwritten by an Origin entry in the headers parameter.

Also, in the absence of an over-riding Origin header, the default should be schema://host[:port] per rfc 6454, not the full url.

I can provide a patch if you wish.

— Reply to this email directly or view it on GitHub https://github.com/Lawouach/WebSocket-for-Python/issues/153.

  • Sylvain http://www.defuze.org http://twitter.com/lawouach

Lawouach avatar Dec 14 '14 21:12 Lawouach

Is this still an issue? I see this: https://github.com/Lawouach/WebSocket-for-Python/blob/master/ws4py/client/init.py#L261

Looks like if the user sets the origin header the client won't add another?

tilgovi avatar Feb 09 '15 17:02 tilgovi

Good catch.

Lawouach avatar Feb 09 '15 17:02 Lawouach

Is this an issue in the 0.3.4 release (the version currently on PyPI)? If so, would it be possible for the PyPI version to be updated?

qrazhan avatar Dec 22 '15 00:12 qrazhan