activemq-cpp-3.9.5
HttpURLConnection.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _DECAF_NET_HTTPURLCONNECTION_H_
19#define _DECAF_NET_HTTPURLCONNECTION_H_
20
21#include <decaf/util/Config.h>
22
26
27namespace decaf {
28namespace net {
29
41 class DECAF_API HttpURLConnection : public URLConnection {
42 protected:
43
47 std::string method;
48
60
64 std::string responseMessage;
65
71
78
85
86 public:
87
91 static const int HTTP_ACCEPTED;
92
96 static const int HTTP_BAD_GATEWAY;
97
101 static const int HTTP_BAD_METHOD;
102
106 static const int HTTP_BAD_REQUEST;
107
111 static const int HTTP_CLIENT_TIMEOUT;
112
116 static const int HTTP_CONFLICT;
117
121 static const int HTTP_CREATED;
122
126 static const int HTTP_ENTITY_TOO_LARGE;
127
131 static const int HTTP_FORBIDDEN;
132
136 static const int HTTP_GATEWAY_TIMEOUT;
137
141 static const int HTTP_GONE;
142
146 static const int HTTP_INTERNAL_ERROR;
147
151 static const int HTTP_LENGTH_REQUIRED;
152
156 static const int HTTP_MOVED_PERM;
157
161 static const int HTTP_MOVED_TEMP;
162
166 static const int HTTP_MULT_CHOICE;
167
171 static const int HTTP_NO_CONTENT;
172
176 static const int HTTP_NOT_ACCEPTABLE;
177
181 static const int HTTP_NOT_AUTHORITATIVE;
182
186 static const int HTTP_NOT_FOUND;
187
191 static const int HTTP_NOT_IMPLEMENTED;
192
196 static const int HTTP_NOT_MODIFIED;
197
201 static const int HTTP_OK;
202
206 static const int HTTP_PARTIAL;
207
211 static const int HTTP_PAYMENT_REQUIRED;
212
216 static const int HTTP_PRECON_FAILED;
217
221 static const int HTTP_PROXY_AUTH;
222
226 static const int HTTP_REQ_TOO_LONG;
227
231 static const int HTTP_RESET;
232
236 static const int HTTP_SEE_OTHER;
237
241 static const int HTTP_USE_PROXY;
242
246 static const int HTTP_UNAUTHORIZED;
247
251 static const int HTTP_UNSUPPORTED_TYPE;
252
256 static const int HTTP_UNAVAILABLE;
257
261 static const int HTTP_VERSION;
262
263 private:
264
265 static bool followRedirects;
266
267 static const int DEFAULT_CHUNK_LENGTH;
268
269 private:
270
271 HttpURLConnection(const HttpURLConnection&);
272 HttpURLConnection& operator= (const HttpURLConnection&);
273
274 protected:
275
277
278 public:
279
281
288 virtual void disconnect() = 0;
289
298 return NULL;
299 }
300
308 std::string getRequestMethod() const {
309 return method;
310 }
311
320
328 std::string getResponseMessage();
329
341 void setRequestMethod(const std::string& method);
342
350 }
351
358 void setInstanceFollowRedirects(bool followRedirects) {
359 instanceFollowRedirects = followRedirects;
360 }
361
373 void setFixedLengthStreamingMode(int contentLength);
374
386 void setChunkedStreamingMode(int chunklen);
387
388 public:
389
396 static bool getFollowRedirects() {
397 return followRedirects;
398 }
399
407 static void setFollowRedirects(bool follow) {
408 followRedirects = follow;
409 }
410
411 };
412
413}}
414
415#endif /* _DECAF_NET_HTTPURLCONNECTION_H_ */
A base class that must be implemented by all classes wishing to provide a class that reads in a strea...
Definition InputStream.h:39
virtual decaf::io::InputStream * getErrorStream() const
Returns an input stream from the server in the case of an error such as the requested file has not be...
Definition HttpURLConnection.h:297
static const int HTTP_FORBIDDEN
Numeric status code, 403: Forbidden.
Definition HttpURLConnection.h:131
static const int HTTP_INTERNAL_ERROR
Numeric status code, 500: Internal error.
Definition HttpURLConnection.h:146
static const int HTTP_ENTITY_TOO_LARGE
Numeric status code, 413: Entity too large.
Definition HttpURLConnection.h:126
static const int HTTP_BAD_REQUEST
Numeric status code, 400: Bad Request.
Definition HttpURLConnection.h:106
static const int HTTP_CLIENT_TIMEOUT
Numeric status code, 408: Client Timeout.
Definition HttpURLConnection.h:111
int getResponseCode()
Returns the response code returned by the remote HTTP server.
static const int HTTP_PROXY_AUTH
Numeric status code, 407: Proxy authentication required.
Definition HttpURLConnection.h:221
static const int HTTP_BAD_GATEWAY
Numeric status code, 502: Bad Gateway.
Definition HttpURLConnection.h:96
static const int HTTP_NO_CONTENT
Numeric status code, 204: No content.
Definition HttpURLConnection.h:171
static const int HTTP_NOT_IMPLEMENTED
Numeric status code, 501: Not implemented.
Definition HttpURLConnection.h:191
bool instanceFollowRedirects
Flag to define whether the protocol will automatically follow redirects or not.
Definition HttpURLConnection.h:70
std::string method
The HTTP request method of this HttpURLConnection.
Definition HttpURLConnection.h:47
static const int HTTP_OK
Numeric status code, 200: OK.
Definition HttpURLConnection.h:201
static const int HTTP_LENGTH_REQUIRED
Numeric status code, 411: Length required.
Definition HttpURLConnection.h:151
int responseCode
The status code of the response obtained from the HTTP request.
Definition HttpURLConnection.h:59
static const int HTTP_UNSUPPORTED_TYPE
Numeric status code, 415: Unsupported type.
Definition HttpURLConnection.h:251
void setFixedLengthStreamingMode(int contentLength)
If the length of a HTTP request body is known ahead, sets fixed length to enable streaming without bu...
static const int HTTP_MOVED_PERM
Numeric status code, 301 Moved permanently.
Definition HttpURLConnection.h:156
static bool getFollowRedirects()
Returns the value of followRedirects which indicates if this connection follows a different URL redir...
Definition HttpURLConnection.h:396
static const int HTTP_USE_PROXY
Numeric status code, 305: Use proxy.
Definition HttpURLConnection.h:241
static const int HTTP_PAYMENT_REQUIRED
Numeric status code, 402: Payment required.
Definition HttpURLConnection.h:211
static const int HTTP_CONFLICT
Numeric status code, 409: Conflict.
Definition HttpURLConnection.h:116
static const int HTTP_MOVED_TEMP
Numeric status code, 302: Moved temporarily.
Definition HttpURLConnection.h:161
std::string getRequestMethod() const
Returns the request method which will be used to make the request to the remote HTTP server.
Definition HttpURLConnection.h:308
void setInstanceFollowRedirects(bool followRedirects)
Sets whether this connection follows redirects.
Definition HttpURLConnection.h:358
static const int HTTP_PRECON_FAILED
Numeric status code, 412: Precondition failed.
Definition HttpURLConnection.h:216
static const int HTTP_NOT_MODIFIED
Numeric status code, 304: Not modified.
Definition HttpURLConnection.h:196
int chunkLength
If the HTTP chunked encoding is enabled this parameter defines the chunk-length.
Definition HttpURLConnection.h:77
static const int HTTP_NOT_FOUND
Numeric status code, 404: Not found.
Definition HttpURLConnection.h:186
static const int HTTP_UNAVAILABLE
Numeric status code, 503: Unavailable.
Definition HttpURLConnection.h:256
std::string responseMessage
The HTTP response message which corresponds to the response code.
Definition HttpURLConnection.h:64
static const int HTTP_ACCEPTED
Numeric status code, 202: Accepted.
Definition HttpURLConnection.h:91
std::string getResponseMessage()
Returns the response message returned by the remote HTTP server.
static const int HTTP_SEE_OTHER
Numeric status code, 303: See other.
Definition HttpURLConnection.h:236
static const int HTTP_CREATED
Numeric status code, 201: Created.
Definition HttpURLConnection.h:121
int fixedContentLength
If using HTTP fixed-length streaming mode this parameter defines the fixed length of content.
Definition HttpURLConnection.h:84
static const int HTTP_UNAUTHORIZED
Numeric status code, 401: Unauthorized.
Definition HttpURLConnection.h:246
static const int HTTP_GATEWAY_TIMEOUT
Numeric status code, 504: Gateway timeout.
Definition HttpURLConnection.h:136
virtual void disconnect()=0
Closes the connection to the HTTP server.
static const int HTTP_VERSION
Numeric status code, 505: Version not supported.
Definition HttpURLConnection.h:261
static const int HTTP_NOT_AUTHORITATIVE
Numeric status code, 203: Not authoritative.
Definition HttpURLConnection.h:181
static const int HTTP_NOT_ACCEPTABLE
Numeric status code, 406: Not acceptable.
Definition HttpURLConnection.h:176
static const int HTTP_GONE
Numeric status code, 410: Gone.
Definition HttpURLConnection.h:141
static const int HTTP_BAD_METHOD
Numeric status code, 405: Bad Method.
Definition HttpURLConnection.h:101
HttpURLConnection(const URL &url)
static void setFollowRedirects(bool follow)
Sets the flag of whether this connection will follow redirects returned by the remote server.
Definition HttpURLConnection.h:407
static const int HTTP_RESET
Numeric status code, 205: Reset.
Definition HttpURLConnection.h:231
static const int HTTP_PARTIAL
Numeric status code, 206: Partial.
Definition HttpURLConnection.h:206
static const int HTTP_REQ_TOO_LONG
Numeric status code, 414: Request too long.
Definition HttpURLConnection.h:226
static const int HTTP_MULT_CHOICE
Numeric status code, 300: Multiple choices.
Definition HttpURLConnection.h:166
bool getInstanceFollowRedirects() const
Returns whether this connection follows redirects.
Definition HttpURLConnection.h:348
void setRequestMethod(const std::string &method)
Sets the request command which will be sent to the remote HTTP server.
void setChunkedStreamingMode(int chunklen)
If the length of a HTTP request body is NOT known ahead, enable chunked transfer encoding to enable s...
URL url
Definition URLConnection.h:52
Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.
Definition URL.h:118
#define NULL
Definition Config.h:33
#define DECAF_API
Definition Config.h:29
Definition URLStreamHandlerManager.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25