OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "net/base/completion_callback.h" | 6 #include "net/base/completion_callback.h" |
7 #include "net/base/net_log_unittest.h" | 7 #include "net/base/net_log_unittest.h" |
8 #include "net/spdy/buffered_spdy_framer.h" | 8 #include "net/spdy/buffered_spdy_framer.h" |
9 #include "net/spdy/spdy_stream.h" | 9 #include "net/spdy/spdy_stream.h" |
10 #include "net/spdy/spdy_http_utils.h" | 10 #include "net/spdy/spdy_http_utils.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 0, | 144 0, |
145 DATA_FLAG_NONE | 145 DATA_FLAG_NONE |
146 }; | 146 }; |
147 static const char* const kGetHeaders[] = { | 147 static const char* const kGetHeaders[] = { |
148 "method", | 148 "method", |
149 "GET", | 149 "GET", |
150 "scheme", | 150 "scheme", |
151 "http", | 151 "http", |
152 "host", | 152 "host", |
153 "www.google.com", | 153 "www.google.com", |
154 "path", | 154 "url", |
155 "/", | 155 "/", |
156 "version", | 156 "version", |
157 "HTTP/1.1", | 157 "HTTP/1.1", |
158 }; | 158 }; |
159 scoped_ptr<SpdyFrame> req( | 159 scoped_ptr<SpdyFrame> req( |
160 ConstructSpdyPacket( | 160 ConstructSpdyPacket( |
161 kSynStartHeader, NULL, 0, kGetHeaders, arraysize(kGetHeaders) / 2)); | 161 kSynStartHeader, NULL, 0, kGetHeaders, arraysize(kGetHeaders) / 2)); |
162 scoped_ptr<SpdyFrame> msg( | 162 scoped_ptr<SpdyFrame> msg( |
163 ConstructSpdyBodyFrame("\0hello!\xff", 8)); | 163 ConstructSpdyBodyFrame("\0hello!\xff", 8)); |
164 MockWrite writes[] = { | 164 MockWrite writes[] = { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 scoped_ptr<TestSpdyStreamDelegate> delegate( | 216 scoped_ptr<TestSpdyStreamDelegate> delegate( |
217 new TestSpdyStreamDelegate(stream.get(), buf.get(), callback.callback())); | 217 new TestSpdyStreamDelegate(stream.get(), buf.get(), callback.callback())); |
218 stream->SetDelegate(delegate.get()); | 218 stream->SetDelegate(delegate.get()); |
219 | 219 |
220 EXPECT_FALSE(stream->HasUrl()); | 220 EXPECT_FALSE(stream->HasUrl()); |
221 | 221 |
222 linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 222 linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
223 (*headers)["method"] = "GET"; | 223 (*headers)["method"] = "GET"; |
224 (*headers)["scheme"] = url.scheme(); | 224 (*headers)["scheme"] = url.scheme(); |
225 (*headers)["host"] = url.host(); | 225 (*headers)["host"] = url.host(); |
226 (*headers)["path"] = url.path(); | 226 (*headers)["url"] = url.path(); |
227 (*headers)["version"] = "HTTP/1.1"; | 227 (*headers)["version"] = "HTTP/1.1"; |
228 stream->set_spdy_headers(headers); | 228 stream->set_spdy_headers(headers); |
229 EXPECT_TRUE(stream->HasUrl()); | 229 EXPECT_TRUE(stream->HasUrl()); |
230 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); | 230 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); |
231 | 231 |
232 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); | 232 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); |
233 | 233 |
234 EXPECT_EQ(OK, callback.WaitForResult()); | 234 EXPECT_EQ(OK, callback.WaitForResult()); |
235 | 235 |
236 EXPECT_TRUE(delegate->send_headers_completed()); | 236 EXPECT_TRUE(delegate->send_headers_completed()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 0, | 315 0, |
316 DATA_FLAG_NONE | 316 DATA_FLAG_NONE |
317 }; | 317 }; |
318 static const char* const kGetHeaders[] = { | 318 static const char* const kGetHeaders[] = { |
319 "method", | 319 "method", |
320 "GET", | 320 "GET", |
321 "scheme", | 321 "scheme", |
322 "http", | 322 "http", |
323 "host", | 323 "host", |
324 "www.google.com", | 324 "www.google.com", |
325 "path", | 325 "url", |
326 "/", | 326 "/", |
327 "version", | 327 "version", |
328 "HTTP/1.1", | 328 "HTTP/1.1", |
329 }; | 329 }; |
330 scoped_ptr<SpdyFrame> req( | 330 scoped_ptr<SpdyFrame> req( |
331 ConstructSpdyPacket( | 331 ConstructSpdyPacket( |
332 kSynStartHeader, NULL, 0, kGetHeaders, arraysize(kGetHeaders) / 2)); | 332 kSynStartHeader, NULL, 0, kGetHeaders, arraysize(kGetHeaders) / 2)); |
333 scoped_ptr<SpdyFrame> msg( | 333 scoped_ptr<SpdyFrame> msg( |
334 ConstructSpdyBodyFrame("\0hello!\xff", 8)); | 334 ConstructSpdyBodyFrame("\0hello!\xff", 8)); |
335 MockWrite writes[] = { | 335 MockWrite writes[] = { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 scoped_ptr<TestSpdyStreamDelegate> delegate( | 389 scoped_ptr<TestSpdyStreamDelegate> delegate( |
390 new TestSpdyStreamDelegate(stream.get(), buf.get(), callback.callback())); | 390 new TestSpdyStreamDelegate(stream.get(), buf.get(), callback.callback())); |
391 stream->SetDelegate(delegate.get()); | 391 stream->SetDelegate(delegate.get()); |
392 | 392 |
393 EXPECT_FALSE(stream->HasUrl()); | 393 EXPECT_FALSE(stream->HasUrl()); |
394 | 394 |
395 linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 395 linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
396 (*headers)["method"] = "GET"; | 396 (*headers)["method"] = "GET"; |
397 (*headers)["scheme"] = url.scheme(); | 397 (*headers)["scheme"] = url.scheme(); |
398 (*headers)["host"] = url.host(); | 398 (*headers)["host"] = url.host(); |
399 (*headers)["path"] = url.path(); | 399 (*headers)["url"] = url.path(); |
400 (*headers)["version"] = "HTTP/1.1"; | 400 (*headers)["version"] = "HTTP/1.1"; |
401 stream->set_spdy_headers(headers); | 401 stream->set_spdy_headers(headers); |
402 EXPECT_TRUE(stream->HasUrl()); | 402 EXPECT_TRUE(stream->HasUrl()); |
403 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); | 403 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); |
404 | 404 |
405 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); | 405 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); |
406 | 406 |
407 const SpdyStreamId stream_id = stream->stream_id(); | 407 const SpdyStreamId stream_id = stream->stream_id(); |
408 | 408 |
409 EXPECT_EQ(OK, callback.WaitForResult()); | 409 EXPECT_EQ(OK, callback.WaitForResult()); |
(...skipping 17 matching lines...) Expand all Loading... |
427 net::NetLog::PHASE_NONE); | 427 net::NetLog::PHASE_NONE); |
428 | 428 |
429 CapturingNetLog::Entry entry = entries[pos]; | 429 CapturingNetLog::Entry entry = entries[pos]; |
430 NetLogSpdyStreamErrorParameter* request_params = | 430 NetLogSpdyStreamErrorParameter* request_params = |
431 static_cast<NetLogSpdyStreamErrorParameter*>( | 431 static_cast<NetLogSpdyStreamErrorParameter*>( |
432 entry.extra_parameters.get()); | 432 entry.extra_parameters.get()); |
433 EXPECT_EQ(stream_id, request_params->stream_id()); | 433 EXPECT_EQ(stream_id, request_params->stream_id()); |
434 } | 434 } |
435 | 435 |
436 } // namespace net | 436 } // namespace net |
OLD | NEW |