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_RESPONSE_H_
16 : #define SYZYGY_KASKO_HTTP_RESPONSE_H_
17 :
18 : #include <stdint.h>
19 : #include "base/strings/string16.h"
20 :
21 : namespace kasko {
22 :
23 : // Provides access to the headers and content of the response to a previously
24 : // issued HTTP request.
25 : class HttpResponse {
26 : public:
27 E : virtual ~HttpResponse() {}
28 :
29 : // Retrieves the response status code.
30 : // @param status_code Receives the status code.
31 : // @returns true if successful.
32 : virtual bool GetStatusCode(uint16_t* status_code) = 0;
33 :
34 : // Retrieves the specified content length, if any.
35 : // @param has_content_length Is set to true if the content length is
36 : // specified.
37 : // @param content_length Receives the content length (if specified).
38 : // @returns true if the content length is retrieved or not specified in the
39 : // response.
40 : virtual bool GetContentLength(bool* has_content_length,
41 : size_t* content_length) = 0;
42 :
43 : // Retrieves the specified Content-Type header value, if any.
44 : // @param has_content_type Is set to true if the content type is
45 : // specified.
46 : // @param content_type Receives the content type (if specified).
47 : // @returns true if the content type is retrieved or not specified in the
48 : // response.
49 : virtual bool GetContentType(bool* has_content_type,
50 : base::string16* content_type) = 0;
51 :
52 : // Checks the response body stream.
53 : // @param has_data Is set to true if data is available to read
54 : // @returns true if successful.
55 : virtual bool HasData(bool* has_data) = 0;
56 :
57 : // Reads from the response body stream.
58 : // @param buffer The location into which data will be read.
59 : // @param count On invocation, the maximum length to read into buffer. Upon
60 : // successful return, the number of bytes read.
61 : // @returns true if successful.
62 : virtual bool ReadData(char* buffer, size_t* count) = 0;
63 : };
64 :
65 : } // namespace kasko
66 :
67 : #endif // SYZYGY_KASKO_HTTP_RESPONSE_H_
|