mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #6611 - jdm:websocketorigin, r=jdm
Add Origin header to WebSocket connections. Closes #6532. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6611) <!-- Reviewable:end -->
This commit is contained in:
commit
0fb9f22ff7
9 changed files with 29 additions and 11 deletions
|
@ -32,6 +32,7 @@ use websocket::client::receiver::Receiver;
|
|||
use websocket::stream::WebSocketStream;
|
||||
use websocket::client::request::Url;
|
||||
use websocket::Client;
|
||||
use websocket::header::Origin;
|
||||
|
||||
#[derive(JSTraceable, PartialEq, Copy, Clone)]
|
||||
enum WebSocketRequestState {
|
||||
|
@ -139,7 +140,7 @@ impl WebSocket {
|
|||
|
||||
// TODO Client::connect does not conform to RFC 6455
|
||||
// see https://github.com/cyderize/rust-websocket/issues/38
|
||||
let request = match Client::connect(url) {
|
||||
let mut request = match Client::connect(url) {
|
||||
Ok(request) => request,
|
||||
Err(_) => {
|
||||
let global_root = ws.r().global.root();
|
||||
|
@ -149,6 +150,7 @@ impl WebSocket {
|
|||
return Ok(ws);
|
||||
}
|
||||
};
|
||||
request.headers.set(Origin(global.get_url().serialize()));
|
||||
let response = request.send().unwrap();
|
||||
response.validate().unwrap();
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
[010.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
expected: TIMEOUT
|
||||
[WebSockets: protocol in response but no requested protocol]
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
[011.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
expected: TIMEOUT
|
||||
[WebSockets: protocol mismatch]
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
[012.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
expected: TIMEOUT
|
||||
[WebSockets: no protocol in response]
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[002.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
[WebSockets: Set-Cookie in response]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[004.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
|
@ -1,3 +1,6 @@
|
|||
[005.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
expected: TIMEOUT
|
||||
[WebSockets: setting HttpOnly cookies in ws response, checking ws request]
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[007.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
[WebSockets: when to process set-cookie fields in ws response]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
[005.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
expected: TIMEOUT
|
||||
[WebSockets: proper first line]
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue