Lawouach / WebSocket-for-Python

WebSocket client and server library for Python 2 and 3 as well as PyPy (ws4py 0.5.1)
https://ws4py.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
1.12k stars 288 forks source link

Add ability to set custom Origin header #153

Open rdbhost opened 9 years ago

rdbhost commented 9 years ago

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.

Lawouach commented 9 years ago

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 notifications@github.com:

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.

tilgovi commented 9 years ago

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?

Lawouach commented 9 years ago

Good catch.

qrazhan commented 8 years ago

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?