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

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

Issue 1421903008: Revert of SSL in EmbeddedTestServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ 5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_
6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ 6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/test/embedded_test_server/http_request.h" 15 #include "net/test/embedded_test_server/http_request.h"
16 #include "net/test/embedded_test_server/http_response.h"
17 16
18 namespace net { 17 namespace net {
19 18
20 class StreamSocket; 19 class StreamSocket;
21 20
22 namespace test_server { 21 namespace test_server {
23 22
24 class HttpConnection; 23 class HttpConnection;
25 class HttpResponse; 24 class HttpResponse;
26 25
27 // Calblack called when a request is parsed. Response should be sent 26 // Calblack called when a request is parsed. Response should be sent
28 // using HttpConnection::SendResponse() on the |connection| argument. 27 // using HttpConnection::SendResponse() on the |connection| argument.
29 typedef base::Callback<void(HttpConnection* connection, 28 typedef base::Callback<void(HttpConnection* connection,
30 scoped_ptr<HttpRequest> request)> 29 scoped_ptr<HttpRequest> request)>
31 HandleRequestCallback; 30 HandleRequestCallback;
32 31
33 // Wraps the connection socket. Accepts incoming data and sends responses. 32 // Wraps the connection socket. Accepts incoming data and sends responses.
34 // If a valid request is parsed, then |callback_| is invoked. 33 // If a valid request is parsed, then |callback_| is invoked.
35 class HttpConnection { 34 class HttpConnection {
36 public: 35 public:
37 HttpConnection(scoped_ptr<StreamSocket> socket, 36 HttpConnection(scoped_ptr<StreamSocket> socket,
38 const HandleRequestCallback& callback); 37 const HandleRequestCallback& callback);
39 ~HttpConnection(); 38 ~HttpConnection();
40 39
41 // Sends the |response_string| to the client and calls |callback| once done. 40 // Sends the HTTP response to the client.
42 void SendResponseBytes(const std::string& response_string, 41 void SendResponse(scoped_ptr<HttpResponse> response,
43 const SendCompleteCallback& callback); 42 const base::Closure& callback);
44 43
45 // Accepts raw chunk of data from the client. Internally, passes it to the 44 // Accepts raw chunk of data from the client. Internally, passes it to the
46 // HttpRequestParser class. If a request is parsed, then |callback_| is 45 // HttpRequestParser class. If a request is parsed, then |callback_| is
47 // called. 46 // called.
48 int ReadData(const CompletionCallback& callback); 47 int ReadData(const CompletionCallback& callback);
49 48
50 bool ConsumeData(int size); 49 bool ConsumeData(int size);
51 50
52 private: 51 private:
53 friend class EmbeddedTestServer; 52 friend class EmbeddedTestServer;
54 53
55 void SendInternal(const base::Closure& callback, 54 void SendInternal(const base::Closure& callback,
56 scoped_refptr<DrainableIOBuffer> buffer); 55 scoped_refptr<DrainableIOBuffer> buffer);
57 void OnSendInternalDone(const base::Closure& callback, 56 void OnSendInternalDone(const base::Closure& callback,
58 scoped_refptr<DrainableIOBuffer> buffer, 57 scoped_refptr<DrainableIOBuffer> buffer,
59 int rv); 58 int rv);
60 59
61 scoped_ptr<StreamSocket> socket_; 60 scoped_ptr<StreamSocket> socket_;
62 const HandleRequestCallback callback_; 61 const HandleRequestCallback callback_;
63 HttpRequestParser request_parser_; 62 HttpRequestParser request_parser_;
64 scoped_refptr<IOBufferWithSize> read_buf_; 63 scoped_refptr<IOBufferWithSize> read_buf_;
65 64
66 DISALLOW_COPY_AND_ASSIGN(HttpConnection); 65 DISALLOW_COPY_AND_ASSIGN(HttpConnection);
67 }; 66 };
68 67
69 } // namespace test_server 68 } // namespace test_server
70 } // namespace net 69 } // namespace net
71 70
72 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ 71 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server_unittest.cc ('k') | net/test/embedded_test_server/http_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698