1 : // Copyright 2014 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #ifndef SYZYGY_KASKO_HTTP_AGENT_H_
16 : #define SYZYGY_KASKO_HTTP_AGENT_H_
17 :
18 : #include <stdint.h>
19 : #include <string>
20 :
21 : #include "base/memory/scoped_ptr.h"
22 : #include "base/strings/string16.h"
23 :
24 : namespace kasko {
25 :
26 : class HttpResponse;
27 :
28 : // Defines an interface for issuing HTTP requests.
29 : class HttpAgent {
30 : public:
31 E : virtual ~HttpAgent() {}
32 :
33 : // Issues an HTTP POST request.
34 : // @param host The target host.
35 : // @param port The target port.
36 : // @param path The resource path.
37 : // @param secure Whether to use HTTPS.
38 : // @param extra_headers Zero or more CRLF-delimited HTTP header lines to
39 : // include in the request.
40 : // @param body The request body.
41 : // @returns NULL if the request fails for any reason. Otherwise, returns an
42 : // HttpResponse that may be used to access the HTTP response.
43 : virtual scoped_ptr<HttpResponse> Post(const base::string16& host,
44 : uint16_t port,
45 : const base::string16& path,
46 : bool secure,
47 : const base::string16& extra_headers,
48 : const std::string& body) = 0;
49 : };
50 :
51 : } // namespace kasko
52 :
53 : #endif // SYZYGY_KASKO_HTTP_AGENT_H_
|