AWS SDK for C++  0.12.9
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 AWS_CORE_API HttpResponseCode
39  {
41  CONTINUE = 100,
43  PROCESSING = 102,
44  OK = 200,
45  CREATED = 201,
46  ACCEPTED = 202,
48  NO_CONTENT = 204,
51  MULTI_STATUS = 207,
53  IM_USED = 226,
56  FOUND = 302,
57  SEE_OTHER = 303,
58  NOT_MODIFIED = 304,
59  USE_PROXY = 305,
60  SWITCH_PROXY = 306,
63  BAD_REQUEST = 400,
64  UNAUTHORIZED = 401,
66  FORBIDDEN = 403,
67  NOT_FOUND = 404,
72  CONFLICT = 409,
73  GONE = 410,
81  IM_A_TEAPOT = 418,
85  LOCKED = 423,
92  NO_RESPONSE = 444,
93  RETRY_WITH = 449,
94  BLOCKED = 450,
95  REDIRECT = 451,
97  CERT_ERROR = 495,
98  NO_CERT = 496,
103  BAD_GATEWAY = 502,
114  NETWORK_CONNECT_TIMEOUT = 599
115  };
116 
121  {
122  public:
126  HttpResponse(const HttpRequest& originatingRequest) :
127  httpRequest(originatingRequest),
128  responseCode(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 
CERT_ERROR
Definition: HttpResponse.h:97
PROCESSING
Definition: HttpResponse.h:43
PAYMENT_REQUIRED
Definition: HttpResponse.h:65
PARTIAL_CONTENT
Definition: HttpResponse.h:50
REQUEST_ENTITY_TOO_LARGE
Definition: HttpResponse.h:76
UNAUTHORIZED
Definition: HttpResponse.h:64
LOCKED
Definition: HttpResponse.h:85
GONE
Definition: HttpResponse.h:73
UPGRADE_REQUIRED
Definition: HttpResponse.h:87
MULTIPLE_CHOICES
Definition: HttpResponse.h:54
FORBIDDEN
Definition: HttpResponse.h:66
USE_PROXY
Definition: HttpResponse.h:59
NON_AUTHORITATIVE_INFORMATION
Definition: HttpResponse.h:47
NETWORK_AUTHENTICATION_REQUIRED
Definition: HttpResponse.h:112
METHOD_FAILURE
Definition: HttpResponse.h:83
BANDWIDTH_LIMIT_EXCEEDED
Definition: HttpResponse.h:110
REQUESTED_RANGE_NOT_SATISFIABLE
Definition: HttpResponse.h:79
LENGTH_REQUIRED
Definition: HttpResponse.h:74
FAILED_DEPENDENCY
Definition: HttpResponse.h:86
virtual void SetContentType(const Aws::String &contentType)
Definition: HttpResponse.h:178
CLIENT_CLOSED_TO_REQUEST
Definition: HttpResponse.h:100
HTTP_VERSION_NOT_SUPPORTED
Definition: HttpResponse.h:106
RETRY_WITH
Definition: HttpResponse.h:93
REQUEST_HEADER_FIELDS_TOO_LARGE
Definition: HttpResponse.h:90
PRECONDITION_REQUIRED
Definition: HttpResponse.h:88
Aws::Map< Aws::String, Aws::String > HeaderValueCollection
Definition: HttpTypes.h:63
SEE_OTHER
Definition: HttpResponse.h:57
BAD_GATEWAY
Definition: HttpResponse.h:103
NOT_MODIFIED
Definition: HttpResponse.h:58
UNSUPPORTED_MEDIA_TYPE
Definition: HttpResponse.h:78
BLOCKED
Definition: HttpResponse.h:94
IM_A_TEAPOT
Definition: HttpResponse.h:81
virtual const Aws::String & GetContentType() const
Definition: HttpResponse.h:161
ALREADY_REPORTED
Definition: HttpResponse.h:52
VARIANT_ALSO_NEGOTIATES
Definition: HttpResponse.h:107
LOOP_DETECTED
Definition: HttpResponse.h:109
FOUND
Definition: HttpResponse.h:56
ACCEPTED
Definition: HttpResponse.h:46
UNPROC_ENTITY
Definition: HttpResponse.h:84
TEMPORARY_REDIRECT
Definition: HttpResponse.h:61
BAD_REQUEST
Definition: HttpResponse.h:63
NOT_ACCEPTABLE
Definition: HttpResponse.h:69
REQUEST_HEADER_TOO_LARGE
Definition: HttpResponse.h:96
INTERNAL_SERVER_ERROR
Definition: HttpResponse.h:101
EXPECTATION_FAILED
Definition: HttpResponse.h:80
REDIRECT
Definition: HttpResponse.h:95
virtual const HttpRequest & GetOriginatingRequest() const
Definition: HttpResponse.h:136
std::basic_iostream< char, std::char_traits< char > > IOStream
Definition: AWSStreamFwd.h:32
NOT_EXTENDED
Definition: HttpResponse.h:111
NO_CERT
Definition: HttpResponse.h:98
REQUEST_NOT_MADE
Definition: HttpResponse.h:40
PERMANENT_REDIRECT
Definition: HttpResponse.h:62
NETWORK_READ_TIMEOUT
Definition: HttpResponse.h:113
AWS_CORE_API const char * CONTENT_TYPE_HEADER
HTTP_TO_HTTPS
Definition: HttpResponse.h:99
PROXY_AUTHENTICATION_REQUIRED
Definition: HttpResponse.h:70
TOO_MANY_REQUESTS
Definition: HttpResponse.h:89
AUTHENTICATION_TIMEOUT
Definition: HttpResponse.h:82
CREATED
Definition: HttpResponse.h:45
SWITCH_PROXY
Definition: HttpResponse.h:60
METHOD_NOT_ALLOWED
Definition: HttpResponse.h:68
MOVED_PERMANENTLY
Definition: HttpResponse.h:55
REQUEST_URI_TOO_LONG
Definition: HttpResponse.h:77
RESET_CONTENT
Definition: HttpResponse.h:49
HttpResponse(const HttpRequest &originatingRequest)
Definition: HttpResponse.h:126
REQUEST_TIMEOUT
Definition: HttpResponse.h:71
PRECONDITION_FAILED
Definition: HttpResponse.h:75
NOT_FOUND
Definition: HttpResponse.h:67
INSUFFICIENT_STORAGE
Definition: HttpResponse.h:108
LOGIN_TIMEOUT
Definition: HttpResponse.h:91
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
CONTINUE
Definition: HttpResponse.h:41
NO_CONTENT
Definition: HttpResponse.h:48
SERVICE_UNAVAILABLE
Definition: HttpResponse.h:104
virtual void SetResponseCode(HttpResponseCode httpResponseCode)
Definition: HttpResponse.h:157
IM_USED
Definition: HttpResponse.h:53
NOT_IMPLEMENTED
Definition: HttpResponse.h:102
MULTI_STATUS
Definition: HttpResponse.h:51
OK
Definition: HttpResponse.h:44
SWITCHING_PROTOCOLS
Definition: HttpResponse.h:42
CONFLICT
Definition: HttpResponse.h:72
NO_RESPONSE
Definition: HttpResponse.h:92
GATEWAY_TIMEOUT
Definition: HttpResponse.h:105
#define AWS_CORE_API
Definition: Core_EXPORTS.h:30
virtual HttpResponseCode GetResponseCode() const
Definition: HttpResponse.h:153
JSON (JavaScript Object Notation).