| Index: net/test/embedded_test_server/http_response.h
|
| diff --git a/net/test/embedded_test_server/http_response.h b/net/test/embedded_test_server/http_response.h
|
| index d4df75b5b85418960e39b54056b1562dfe4c4d39..1b58d8abcda3a445781fd3eac0c0ddeb6d07ccf2 100644
|
| --- a/net/test/embedded_test_server/http_response.h
|
| +++ b/net/test/embedded_test_server/http_response.h
|
| @@ -9,6 +9,7 @@
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/callback.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/strings/string_split.h"
|
| #include "net/http/http_status_code.h"
|
| @@ -16,15 +17,22 @@
|
| namespace net {
|
| namespace test_server {
|
|
|
| +// Callback called when the response is done being sent.
|
| +typedef base::Callback<void(void)> SendDoneCallback;
|
| +
|
| +// Callback called when the response is ready to be sent.
|
| +typedef base::Callback<void(std::string response, SendDoneCallback done)>
|
| + SendCallback;
|
| +
|
| // Interface for HTTP response implementations.
|
| class HttpResponse{
|
| public:
|
| virtual ~HttpResponse();
|
|
|
| - // Returns raw contents to be written to the network socket
|
| + // Calls |send| with the raw contents to be written to the network socket
|
| // in response. If you intend to make this a valid HTTP response,
|
| // it should start with "HTTP/x.x" line, followed by response headers.
|
| - virtual std::string ToResponseString() const = 0;
|
| + virtual void SendResponse(SendCallback send, SendDoneCallback done) = 0;
|
| };
|
|
|
| // This class is used to handle basic HTTP responses with commonly used
|
| @@ -54,7 +62,9 @@ class BasicHttpResponse : public HttpResponse {
|
| }
|
|
|
| // Generates and returns a http response string.
|
| - std::string ToResponseString() const override;
|
| + std::string ToResponseString() const;
|
| +
|
| + void SendResponse(SendCallback send, SendDoneCallback done) override;
|
|
|
| private:
|
| HttpStatusCode code_;
|
|
|