AWS SDK for C++  0.14.3
AWS SDK for C++
HttpResponse.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
23 
24 namespace Aws
25 {
26  namespace Utils
27  {
28  namespace Stream
29  {
30  class ResponseStream;
31  }
32  }
33  namespace Http
34  {
38  enum class HttpResponseCode
39  {
40  REQUEST_NOT_MADE = -1,
41  CONTINUE = 100,
42  SWITCHING_PROTOCOLS = 101,
43  PROCESSING = 102,
44  OK = 200,
45  CREATED = 201,
46  ACCEPTED = 202,
48  NO_CONTENT = 204,
49  RESET_CONTENT = 205,
50  PARTIAL_CONTENT = 206,
51  MULTI_STATUS = 207,
52  ALREADY_REPORTED = 208,
53  IM_USED = 226,
54  MULTIPLE_CHOICES = 300,
55  MOVED_PERMANENTLY = 301,
56  FOUND = 302,
57  SEE_OTHER = 303,
58  NOT_MODIFIED = 304,
59  USE_PROXY = 305,
60  SWITCH_PROXY = 306,
61  TEMPORARY_REDIRECT = 307,
62  PERMANENT_REDIRECT = 308,
63  BAD_REQUEST = 400,
64  UNAUTHORIZED = 401,
65  PAYMENT_REQUIRED = 402,
66  FORBIDDEN = 403,
67  NOT_FOUND = 404,
68  METHOD_NOT_ALLOWED = 405,
69  NOT_ACCEPTABLE = 406,
71  REQUEST_TIMEOUT = 408,
72  CONFLICT = 409,
73  GONE = 410,
74  LENGTH_REQUIRED = 411,
75  PRECONDITION_FAILED = 412,
80  EXPECTATION_FAILED = 417,
81  IM_A_TEAPOT = 418,
83  METHOD_FAILURE = 420,
84  UNPROC_ENTITY = 422,
85  LOCKED = 423,
86  FAILED_DEPENDENCY = 424,
87  UPGRADE_REQUIRED = 426,
89  TOO_MANY_REQUESTS = 429,
91  LOGIN_TIMEOUT = 440,
92  NO_RESPONSE = 444,
93  RETRY_WITH = 449,
94  BLOCKED = 450,
95  REDIRECT = 451,
97  CERT_ERROR = 495,
98  NO_CERT = 496,
99  HTTP_TO_HTTPS = 497,
101  INTERNAL_SERVER_ERROR = 500,
102  NOT_IMPLEMENTED = 501,
103  BAD_GATEWAY = 502,
104  SERVICE_UNAVAILABLE = 503,
105  GATEWAY_TIMEOUT = 504,
108  INSUFFICIENT_STORAGE = 506,
109  LOOP_DETECTED = 508,
111  NOT_EXTENDED = 510,
113  NETWORK_READ_TIMEOUT = 598,
115  };
116 
121  {
122  public:
126  HttpResponse(const HttpRequest& originatingRequest) :
127  httpRequest(originatingRequest),
128  responseCode(HttpResponseCode::REQUEST_NOT_MADE)
129  {}
130 
131  virtual ~HttpResponse() = default;
132 
136  virtual inline const HttpRequest& GetOriginatingRequest() const { return httpRequest; }
137 
141  virtual HeaderValueCollection GetHeaders() const = 0;
145  virtual bool HasHeader(const char* headerName) const = 0;
149  virtual const Aws::String& GetHeader(const Aws::String& headerName) const = 0;
153  virtual inline HttpResponseCode GetResponseCode() const { return responseCode; }
157  virtual inline void SetResponseCode(HttpResponseCode httpResponseCode) { responseCode = httpResponseCode; }
161  virtual const Aws::String& GetContentType() const { return GetHeader(Http::CONTENT_TYPE_HEADER); };
165  virtual Aws::IOStream& GetResponseBody() const = 0;
170  virtual Utils::Stream::ResponseStream&& SwapResponseStreamOwnership() = 0;
174  virtual void AddHeader(const Aws::String&, const Aws::String&) = 0;
178  virtual void SetContentType(const Aws::String& contentType) { AddHeader("content-type", contentType); };
179 
180  private:
181  HttpResponse(const HttpResponse&);
182  HttpResponse& operator = (const HttpResponse&);
183 
184  const HttpRequest& httpRequest;
185  HttpResponseCode responseCode;
186  };
187 
188 
189  } // namespace Http
190 } // namespace Aws
191 
192 
virtual void SetContentType(const Aws::String &contentType)
Definition: HttpResponse.h:178
Aws::Map< Aws::String, Aws::String > HeaderValueCollection
Definition: HttpTypes.h:63
virtual const Aws::String & GetContentType() const
Definition: HttpResponse.h:161
virtual const HttpRequest & GetOriginatingRequest() const
Definition: HttpResponse.h:136
std::basic_iostream< char, std::char_traits< char > > IOStream
Definition: AWSStreamFwd.h:32
AWS_CORE_API const char * CONTENT_TYPE_HEADER
HttpResponse(const HttpRequest &originatingRequest)
Definition: HttpResponse.h:126
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
virtual void SetResponseCode(HttpResponseCode httpResponseCode)
Definition: HttpResponse.h:157
#define AWS_CORE_API
Definition: Core_EXPORTS.h:35
virtual HttpResponseCode GetResponseCode() const
Definition: HttpResponse.h:153
JSON (JavaScript Object Notation).