1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_websocket_stream.h"
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
12 #include "net/base/completion_callback.h"
13 #include "net/proxy/proxy_server.h"
14 #include "net/socket/ssl_client_socket.h"
15 #include "net/spdy/spdy_http_utils.h"
16 #include "net/spdy/spdy_protocol.h"
17 #include "net/spdy/spdy_session.h"
18 #include "net/spdy/spdy_test_util_spdy3.h"
19 #include "net/spdy/spdy_websocket_test_util_spdy3.h"
20 #include "testing/gtest/include/gtest/gtest.h"
22 using namespace net::test_spdy3
;
28 struct SpdyWebSocketStreamEvent
{
32 EVENT_RECEIVED_HEADER
,
37 SpdyWebSocketStreamEvent(EventType type
,
38 const SpdyHeaderBlock
& headers
,
40 const std::string
& data
)
47 SpdyHeaderBlock headers
;
52 class SpdyWebSocketStreamEventRecorder
: public SpdyWebSocketStream::Delegate
{
54 explicit SpdyWebSocketStreamEventRecorder(const CompletionCallback
& callback
)
55 : callback_(callback
) {}
56 virtual ~SpdyWebSocketStreamEventRecorder() {}
58 typedef base::Callback
<void(SpdyWebSocketStreamEvent
*)> StreamEventCallback
;
60 void SetOnCreated(const StreamEventCallback
& callback
) {
61 on_created_
= callback
;
63 void SetOnSentHeaders(const StreamEventCallback
& callback
) {
64 on_sent_headers_
= callback
;
66 void SetOnReceivedHeader(const StreamEventCallback
& callback
) {
67 on_received_header_
= callback
;
69 void SetOnSentData(const StreamEventCallback
& callback
) {
70 on_sent_data_
= callback
;
72 void SetOnReceivedData(const StreamEventCallback
& callback
) {
73 on_received_data_
= callback
;
75 void SetOnClose(const StreamEventCallback
& callback
) {
79 virtual void OnCreatedSpdyStream(int result
) {
81 SpdyWebSocketStreamEvent(SpdyWebSocketStreamEvent::EVENT_CREATED
,
85 if (!on_created_
.is_null())
86 on_created_
.Run(&events_
.back());
88 virtual void OnSentSpdyHeaders(int result
) {
90 SpdyWebSocketStreamEvent(SpdyWebSocketStreamEvent::EVENT_SENT_HEADERS
,
94 if (!on_sent_data_
.is_null())
95 on_sent_data_
.Run(&events_
.back());
97 virtual int OnReceivedSpdyResponseHeader(
98 const SpdyHeaderBlock
& headers
, int status
) {
100 SpdyWebSocketStreamEvent(
101 SpdyWebSocketStreamEvent::EVENT_RECEIVED_HEADER
,
105 if (!on_received_header_
.is_null())
106 on_received_header_
.Run(&events_
.back());
109 virtual void OnSentSpdyData(int amount_sent
) {
111 SpdyWebSocketStreamEvent(
112 SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
116 if (!on_sent_data_
.is_null())
117 on_sent_data_
.Run(&events_
.back());
119 virtual void OnReceivedSpdyData(const char* data
, int length
) {
121 SpdyWebSocketStreamEvent(
122 SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
125 std::string(data
, length
)));
126 if (!on_received_data_
.is_null())
127 on_received_data_
.Run(&events_
.back());
129 virtual void OnCloseSpdyStream() {
131 SpdyWebSocketStreamEvent(
132 SpdyWebSocketStreamEvent::EVENT_CLOSE
,
136 if (!on_close_
.is_null())
137 on_close_
.Run(&events_
.back());
138 if (!callback_
.is_null())
142 const std::vector
<SpdyWebSocketStreamEvent
>& GetSeenEvents() const {
147 std::vector
<SpdyWebSocketStreamEvent
> events_
;
148 StreamEventCallback on_created_
;
149 StreamEventCallback on_sent_headers_
;
150 StreamEventCallback on_received_header_
;
151 StreamEventCallback on_sent_data_
;
152 StreamEventCallback on_received_data_
;
153 StreamEventCallback on_close_
;
154 CompletionCallback callback_
;
156 DISALLOW_COPY_AND_ASSIGN(SpdyWebSocketStreamEventRecorder
);
161 class SpdyWebSocketStreamSpdy3Test
: public testing::Test
{
163 OrderedSocketData
* data() { return data_
.get(); }
165 void DoSendHelloFrame(SpdyWebSocketStreamEvent
* event
) {
166 // Record the actual stream_id.
167 created_stream_id_
= websocket_stream_
->stream_
->stream_id();
168 websocket_stream_
->SendData(kMessageFrame
, kMessageFrameLength
);
171 void DoSendClosingFrame(SpdyWebSocketStreamEvent
* event
) {
172 websocket_stream_
->SendData(kClosingFrame
, kClosingFrameLength
);
175 void DoClose(SpdyWebSocketStreamEvent
* event
) {
176 websocket_stream_
->Close();
179 void DoSync(SpdyWebSocketStreamEvent
* event
) {
180 sync_callback_
.callback().Run(OK
);
184 SpdyWebSocketStreamSpdy3Test() {}
185 virtual ~SpdyWebSocketStreamSpdy3Test() {}
187 virtual void SetUp() {
188 host_port_pair_
.set_host("example.com");
189 host_port_pair_
.set_port(80);
190 host_port_proxy_pair_
.first
= host_port_pair_
;
191 host_port_proxy_pair_
.second
= ProxyServer::Direct();
193 spdy_settings_id_to_set_
= SETTINGS_MAX_CONCURRENT_STREAMS
;
194 spdy_settings_flags_to_set_
= SETTINGS_FLAG_PLEASE_PERSIST
;
195 spdy_settings_value_to_set_
= 1;
197 spdy_settings_to_send_
[spdy_settings_id_to_set_
] =
198 SettingsFlagsAndValue(
199 SETTINGS_FLAG_PERSISTED
, spdy_settings_value_to_set_
);
202 virtual void TearDown() {
203 MessageLoop::current()->RunUntilIdle();
206 void Prepare(SpdyStreamId stream_id
) {
207 stream_id_
= stream_id
;
209 request_frame_
.reset(ConstructSpdyWebSocketSynStream(
213 "http://example.com/wsdemo"));
215 response_frame_
.reset(ConstructSpdyWebSocketSynReply(stream_id_
));
217 message_frame_
.reset(ConstructSpdyWebSocketDataFrame(
223 closing_frame_
.reset(ConstructSpdyWebSocketDataFrame(
230 int InitSession(MockRead
* reads
, size_t reads_count
,
231 MockWrite
* writes
, size_t writes_count
,
233 data_
.reset(new OrderedSocketData(reads
, reads_count
,
234 writes
, writes_count
));
235 session_deps_
.socket_factory
->AddSocketDataProvider(data_
.get());
236 http_session_
= SpdySessionDependencies::SpdyCreateSession(&session_deps_
);
237 SpdySessionPool
* spdy_session_pool(http_session_
->spdy_session_pool());
240 // Set max concurrent streams to 1.
241 spdy_session_pool
->http_server_properties()->SetSpdySetting(
243 spdy_settings_id_to_set_
,
244 spdy_settings_flags_to_set_
,
245 spdy_settings_value_to_set_
);
248 EXPECT_FALSE(spdy_session_pool
->HasSession(host_port_proxy_pair_
));
249 session_
= spdy_session_pool
->Get(host_port_proxy_pair_
, BoundNetLog());
250 EXPECT_TRUE(spdy_session_pool
->HasSession(host_port_proxy_pair_
));
251 transport_params_
= new TransportSocketParams(host_port_pair_
, MEDIUM
,
253 OnHostResolutionCallback());
254 TestCompletionCallback callback
;
255 scoped_ptr
<ClientSocketHandle
> connection(new ClientSocketHandle
);
256 EXPECT_EQ(ERR_IO_PENDING
,
257 connection
->Init(host_port_pair_
.ToString(), transport_params_
,
258 MEDIUM
, callback
.callback(),
259 http_session_
->GetTransportSocketPool(
260 HttpNetworkSession::NORMAL_SOCKET_POOL
),
262 EXPECT_EQ(OK
, callback
.WaitForResult());
263 return session_
->InitializeWithSocket(connection
.release(), false, OK
);
267 scoped_ptr
<SpdyHeaderBlock
> headers(new SpdyHeaderBlock
);
268 (*headers
)[":path"] = "/echo";
269 (*headers
)[":host"] = "example.com";
270 (*headers
)[":version"] = "WebSocket/13";
271 (*headers
)[":scheme"] = "ws";
272 (*headers
)[":origin"] = "http://example.com/wsdemo";
274 websocket_stream_
->SendRequest(headers
.Pass());
277 SpdySettingsIds spdy_settings_id_to_set_
;
278 SpdySettingsFlags spdy_settings_flags_to_set_
;
279 uint32 spdy_settings_value_to_set_
;
280 SettingsMap spdy_settings_to_send_
;
281 SpdySessionDependencies session_deps_
;
282 scoped_ptr
<OrderedSocketData
> data_
;
283 scoped_refptr
<HttpNetworkSession
> http_session_
;
284 scoped_refptr
<SpdySession
> session_
;
285 scoped_refptr
<TransportSocketParams
> transport_params_
;
286 scoped_ptr
<SpdyWebSocketStream
> websocket_stream_
;
287 SpdyStreamId stream_id_
;
288 SpdyStreamId created_stream_id_
;
289 scoped_ptr
<SpdyFrame
> request_frame_
;
290 scoped_ptr
<SpdyFrame
> response_frame_
;
291 scoped_ptr
<SpdyFrame
> message_frame_
;
292 scoped_ptr
<SpdyFrame
> closing_frame_
;
293 HostPortPair host_port_pair_
;
294 HostPortProxyPair host_port_proxy_pair_
;
295 TestCompletionCallback completion_callback_
;
296 TestCompletionCallback sync_callback_
;
298 static const char kMessageFrame
[];
299 static const char kClosingFrame
[];
300 static const size_t kMessageFrameLength
;
301 static const size_t kClosingFrameLength
;
304 // TODO(toyoshim): Replace old framing data to new one, then use HEADERS and
306 const char SpdyWebSocketStreamSpdy3Test::kMessageFrame
[] = "\x81\x05hello";
307 const char SpdyWebSocketStreamSpdy3Test::kClosingFrame
[] = "\x88\0";
308 const size_t SpdyWebSocketStreamSpdy3Test::kMessageFrameLength
=
309 arraysize(SpdyWebSocketStreamSpdy3Test::kMessageFrame
) - 1;
310 const size_t SpdyWebSocketStreamSpdy3Test::kClosingFrameLength
=
311 arraysize(SpdyWebSocketStreamSpdy3Test::kClosingFrame
) - 1;
313 TEST_F(SpdyWebSocketStreamSpdy3Test
, Basic
) {
315 MockWrite writes
[] = {
316 CreateMockWrite(*request_frame_
.get(), 1),
317 CreateMockWrite(*message_frame_
.get(), 3),
318 CreateMockWrite(*closing_frame_
.get(), 5)
322 CreateMockRead(*response_frame_
.get(), 2),
323 CreateMockRead(*message_frame_
.get(), 4),
324 // Skip sequence 6 to notify closing has been sent.
325 CreateMockRead(*closing_frame_
.get(), 7),
326 MockRead(SYNCHRONOUS
, 0, 8) // EOF cause OnCloseSpdyStream event.
329 EXPECT_EQ(OK
, InitSession(reads
, arraysize(reads
),
330 writes
, arraysize(writes
), false));
332 SpdyWebSocketStreamEventRecorder
delegate(completion_callback_
.callback());
333 delegate
.SetOnReceivedHeader(
334 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSendHelloFrame
,
335 base::Unretained(this)));
336 delegate
.SetOnReceivedData(
337 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSendClosingFrame
,
338 base::Unretained(this)));
340 websocket_stream_
.reset(new SpdyWebSocketStream(session_
, &delegate
));
343 GURL
url("ws://example.com/echo");
344 ASSERT_EQ(OK
, websocket_stream_
->InitializeStream(url
, HIGHEST
, net_log
));
346 ASSERT_TRUE(websocket_stream_
->stream_
);
350 completion_callback_
.WaitForResult();
352 EXPECT_EQ(stream_id_
, created_stream_id_
);
354 websocket_stream_
.reset();
356 const std::vector
<SpdyWebSocketStreamEvent
>& events
=
357 delegate
.GetSeenEvents();
358 ASSERT_EQ(7U, events
.size());
360 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_HEADERS
,
361 events
[0].event_type
);
362 EXPECT_LT(0, events
[0].result
);
363 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_HEADER
,
364 events
[1].event_type
);
365 EXPECT_EQ(OK
, events
[1].result
);
366 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
367 events
[2].event_type
);
368 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[2].result
);
369 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
370 events
[3].event_type
);
371 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[3].result
);
372 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
373 events
[4].event_type
);
374 EXPECT_EQ(static_cast<int>(kClosingFrameLength
), events
[4].result
);
375 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
376 events
[5].event_type
);
377 EXPECT_EQ(static_cast<int>(kClosingFrameLength
), events
[5].result
);
378 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_CLOSE
,
379 events
[6].event_type
);
380 EXPECT_EQ(OK
, events
[6].result
);
382 // EOF close SPDY session.
383 EXPECT_TRUE(!http_session_
->spdy_session_pool()->HasSession(
384 host_port_proxy_pair_
));
385 EXPECT_TRUE(data()->at_read_eof());
386 EXPECT_TRUE(data()->at_write_eof());
389 TEST_F(SpdyWebSocketStreamSpdy3Test
, DestructionBeforeClose
) {
391 MockWrite writes
[] = {
392 CreateMockWrite(*request_frame_
.get(), 1),
393 CreateMockWrite(*message_frame_
.get(), 3)
397 CreateMockRead(*response_frame_
.get(), 2),
398 CreateMockRead(*message_frame_
.get(), 4),
399 MockRead(ASYNC
, ERR_IO_PENDING
, 5)
402 EXPECT_EQ(OK
, InitSession(reads
, arraysize(reads
),
403 writes
, arraysize(writes
), false));
405 SpdyWebSocketStreamEventRecorder
delegate(completion_callback_
.callback());
406 delegate
.SetOnReceivedHeader(
407 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSendHelloFrame
,
408 base::Unretained(this)));
409 delegate
.SetOnReceivedData(
410 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSync
,
411 base::Unretained(this)));
413 websocket_stream_
.reset(new SpdyWebSocketStream(session_
, &delegate
));
416 GURL
url("ws://example.com/echo");
417 ASSERT_EQ(OK
, websocket_stream_
->InitializeStream(url
, HIGHEST
, net_log
));
421 sync_callback_
.WaitForResult();
423 // WebSocketStream destruction remove its SPDY stream from the session.
424 EXPECT_TRUE(session_
->IsStreamActive(stream_id_
));
425 websocket_stream_
.reset();
426 EXPECT_FALSE(session_
->IsStreamActive(stream_id_
));
428 const std::vector
<SpdyWebSocketStreamEvent
>& events
=
429 delegate
.GetSeenEvents();
430 ASSERT_GE(4U, events
.size());
432 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_HEADERS
,
433 events
[0].event_type
);
434 EXPECT_LT(0, events
[0].result
);
435 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_HEADER
,
436 events
[1].event_type
);
437 EXPECT_EQ(OK
, events
[1].result
);
438 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
439 events
[2].event_type
);
440 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[2].result
);
441 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
442 events
[3].event_type
);
443 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[3].result
);
445 EXPECT_TRUE(http_session_
->spdy_session_pool()->HasSession(
446 host_port_proxy_pair_
));
447 EXPECT_TRUE(data()->at_read_eof());
448 EXPECT_TRUE(data()->at_write_eof());
451 TEST_F(SpdyWebSocketStreamSpdy3Test
, DestructionAfterExplicitClose
) {
453 MockWrite writes
[] = {
454 CreateMockWrite(*request_frame_
.get(), 1),
455 CreateMockWrite(*message_frame_
.get(), 3),
456 CreateMockWrite(*closing_frame_
.get(), 5)
460 CreateMockRead(*response_frame_
.get(), 2),
461 CreateMockRead(*message_frame_
.get(), 4),
462 MockRead(ASYNC
, ERR_IO_PENDING
, 6)
465 EXPECT_EQ(OK
, InitSession(reads
, arraysize(reads
),
466 writes
, arraysize(writes
), false));
468 SpdyWebSocketStreamEventRecorder
delegate(completion_callback_
.callback());
469 delegate
.SetOnReceivedHeader(
470 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSendHelloFrame
,
471 base::Unretained(this)));
472 delegate
.SetOnReceivedData(
473 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoClose
,
474 base::Unretained(this)));
476 websocket_stream_
.reset(new SpdyWebSocketStream(session_
, &delegate
));
479 GURL
url("ws://example.com/echo");
480 ASSERT_EQ(OK
, websocket_stream_
->InitializeStream(url
, HIGHEST
, net_log
));
484 completion_callback_
.WaitForResult();
486 // SPDY stream has already been removed from the session by Close().
487 EXPECT_FALSE(session_
->IsStreamActive(stream_id_
));
488 websocket_stream_
.reset();
490 const std::vector
<SpdyWebSocketStreamEvent
>& events
=
491 delegate
.GetSeenEvents();
492 ASSERT_EQ(5U, events
.size());
494 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_HEADERS
,
495 events
[0].event_type
);
496 EXPECT_LT(0, events
[0].result
);
497 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_HEADER
,
498 events
[1].event_type
);
499 EXPECT_EQ(OK
, events
[1].result
);
500 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
501 events
[2].event_type
);
502 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[2].result
);
503 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
504 events
[3].event_type
);
505 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[3].result
);
506 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_CLOSE
, events
[4].event_type
);
508 EXPECT_TRUE(http_session_
->spdy_session_pool()->HasSession(
509 host_port_proxy_pair_
));
512 TEST_F(SpdyWebSocketStreamSpdy3Test
, IOPending
) {
514 scoped_ptr
<SpdyFrame
> settings_frame(
515 ConstructSpdySettings(spdy_settings_to_send_
));
516 MockWrite writes
[] = {
517 // Setting throttling make SpdySession send settings frame automatically.
518 CreateMockWrite(*settings_frame
.get(), 1),
519 CreateMockWrite(*request_frame_
.get(), 3),
520 CreateMockWrite(*message_frame_
.get(), 6),
521 CreateMockWrite(*closing_frame_
.get(), 9)
525 CreateMockRead(*settings_frame
.get(), 2),
526 CreateMockRead(*response_frame_
.get(), 4),
527 // Skip sequence 5 (I/O Pending)
528 CreateMockRead(*message_frame_
.get(), 7),
529 // Skip sequence 8 (I/O Pending)
530 CreateMockRead(*closing_frame_
.get(), 10),
531 MockRead(SYNCHRONOUS
, 0, 11) // EOF cause OnCloseSpdyStream event.
534 EXPECT_EQ(OK
, InitSession(reads
, arraysize(reads
),
535 writes
, arraysize(writes
), true));
537 // Create a dummy WebSocketStream which cause ERR_IO_PENDING to another
538 // WebSocketStream under test.
539 SpdyWebSocketStreamEventRecorder
block_delegate((CompletionCallback()));
541 scoped_ptr
<SpdyWebSocketStream
> block_stream(
542 new SpdyWebSocketStream(session_
, &block_delegate
));
543 BoundNetLog block_net_log
;
544 GURL
block_url("ws://example.com/block");
546 block_stream
->InitializeStream(block_url
, HIGHEST
, block_net_log
));
548 // Create a WebSocketStream under test.
549 SpdyWebSocketStreamEventRecorder
delegate(completion_callback_
.callback());
550 delegate
.SetOnCreated(
551 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSync
,
552 base::Unretained(this)));
553 delegate
.SetOnReceivedHeader(
554 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSendHelloFrame
,
555 base::Unretained(this)));
556 delegate
.SetOnReceivedData(
557 base::Bind(&SpdyWebSocketStreamSpdy3Test::DoSendClosingFrame
,
558 base::Unretained(this)));
560 websocket_stream_
.reset(new SpdyWebSocketStream(session_
, &delegate
));
562 GURL
url("ws://example.com/echo");
563 ASSERT_EQ(ERR_IO_PENDING
, websocket_stream_
->InitializeStream(
564 url
, HIGHEST
, net_log
));
566 // Delete the first stream to allow create the second stream.
567 block_stream
.reset();
568 ASSERT_EQ(OK
, sync_callback_
.WaitForResult());
572 completion_callback_
.WaitForResult();
574 websocket_stream_
.reset();
576 const std::vector
<SpdyWebSocketStreamEvent
>& block_events
=
577 block_delegate
.GetSeenEvents();
578 ASSERT_EQ(0U, block_events
.size());
580 const std::vector
<SpdyWebSocketStreamEvent
>& events
=
581 delegate
.GetSeenEvents();
582 ASSERT_EQ(8U, events
.size());
583 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_CREATED
,
584 events
[0].event_type
);
585 EXPECT_EQ(0, events
[0].result
);
586 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_HEADERS
,
587 events
[1].event_type
);
588 EXPECT_LT(0, events
[1].result
);
589 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_HEADER
,
590 events
[2].event_type
);
591 EXPECT_EQ(OK
, events
[2].result
);
592 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
593 events
[3].event_type
);
594 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[3].result
);
595 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
596 events
[4].event_type
);
597 EXPECT_EQ(static_cast<int>(kMessageFrameLength
), events
[4].result
);
598 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_SENT_DATA
,
599 events
[5].event_type
);
600 EXPECT_EQ(static_cast<int>(kClosingFrameLength
), events
[5].result
);
601 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_RECEIVED_DATA
,
602 events
[6].event_type
);
603 EXPECT_EQ(static_cast<int>(kClosingFrameLength
), events
[6].result
);
604 EXPECT_EQ(SpdyWebSocketStreamEvent::EVENT_CLOSE
,
605 events
[7].event_type
);
606 EXPECT_EQ(OK
, events
[7].result
);
608 // EOF close SPDY session.
609 EXPECT_TRUE(!http_session_
->spdy_session_pool()->HasSession(
610 host_port_proxy_pair_
));
611 EXPECT_TRUE(data()->at_read_eof());
612 EXPECT_TRUE(data()->at_write_eof());