Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: net/test/embedded_test_server/http_connection.cc

Issue 1376593007: SSL in EmbeddedTestServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "net/test/embedded_test_server/http_connection.h" 5 #include "net/test/embedded_test_server/http_connection.h"
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/socket/stream_socket.h" 8 #include "net/socket/stream_socket.h"
9 #include "net/test/embedded_test_server/http_response.h"
10 9
11 namespace net { 10 namespace net {
12 namespace test_server { 11 namespace test_server {
13 12
14 HttpConnection::HttpConnection(scoped_ptr<StreamSocket> socket, 13 HttpConnection::HttpConnection(scoped_ptr<StreamSocket> socket,
15 const HandleRequestCallback& callback) 14 const HandleRequestCallback& callback)
16 : socket_(socket.Pass()), 15 : socket_(socket.Pass()),
17 callback_(callback), 16 callback_(callback),
18 read_buf_(new IOBufferWithSize(4096)) {} 17 read_buf_(new IOBufferWithSize(4096)) {}
19 18
20 HttpConnection::~HttpConnection() { 19 HttpConnection::~HttpConnection() {
21 } 20 }
22 21
23 void HttpConnection::SendResponse(scoped_ptr<HttpResponse> response, 22 void HttpConnection::SendResponse(std::string response_string,
24 const base::Closure& callback) { 23 SendDoneCallback callback) {
25 const std::string response_string = response->ToResponseString();
26 if (response_string.length() > 0) { 24 if (response_string.length() > 0) {
27 scoped_refptr<DrainableIOBuffer> write_buf(new DrainableIOBuffer( 25 scoped_refptr<DrainableIOBuffer> write_buf(new DrainableIOBuffer(
28 new StringIOBuffer(response_string), response_string.length())); 26 new StringIOBuffer(response_string), response_string.length()));
29 27
30 SendInternal(callback, write_buf); 28 SendInternal(callback, write_buf);
31 } else { 29 } else {
32 callback.Run(); 30 callback.Run();
33 } 31 }
34 } 32 }
35 33
(...skipping 29 matching lines...) Expand all
65 request_parser_.ProcessChunk(base::StringPiece(read_buf_->data(), size)); 63 request_parser_.ProcessChunk(base::StringPiece(read_buf_->data(), size));
66 if (request_parser_.ParseRequest() == HttpRequestParser::ACCEPTED) { 64 if (request_parser_.ParseRequest() == HttpRequestParser::ACCEPTED) {
67 callback_.Run(this, request_parser_.GetRequest()); 65 callback_.Run(this, request_parser_.GetRequest());
68 return true; 66 return true;
69 } 67 }
70 return false; 68 return false;
71 } 69 }
72 70
73 } // namespace test_server 71 } // namespace test_server
74 } // namespace net 72 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698