activemq-cpp-3.9.5
URLConnection.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_URLCONNECTION_H_
19#define _DECAF_NET_URLCONNECTION_H_
20
21#include <decaf/util/Config.h>
22
25#include <decaf/net/URL.h>
27
28namespace decaf {
29namespace net {
30
31 class URLConnectionImpl;
32
41 class DECAF_API URLConnection {
42 private:
43
44 URLConnectionImpl* impl;
45
46 static bool defaultAllowUserInteraction;
47
48 static bool defaultUseCaches;
49
50 protected:
51
53
58 long long ifModifiedSince;
59
65
72
77
81 bool doInput;
82
88
89 private:
90
91 URLConnection(const URLConnection&);
92 URLConnection& operator= (const URLConnection&);
93
94 protected:
95
97
98 public:
99
100 virtual ~URLConnection();
101
108 virtual void connect() = 0;
109
110 public:
111
120 }
121
132 void setAllowUserInteraction(bool newValue);
133
140 std::string getContentEncoding() const {
141 return getHeaderField("Content-Encoding");
142 }
143
150 int getContentLength() const {
151 return getHeaderFieldInt("Content-Length", -1);
152 }
153
160 std::string getContentType() const {
161 return getHeaderField("Content-Type");
162 }
163
171 long long getDate() const {
172 return getHeaderFieldDate("Date", 0);
173 }
174
180 bool getDefaultUseCaches() const {
181 return defaultUseCaches;
182 }
183
191 void setDefaultUseCaches(bool newValue);
192
199 bool getDoInput() const {
200 return doInput;
201 }
202
213 void setDoInput(bool newValue);
214
221 bool getDoOutput() const {
222 return doOutput;
223 }
224
235 void setDoOutput(bool newValue);
236
243 long getExpiration() const {
244 return getHeaderFieldDate("Expires", 0);
245 }
246
252 URL getURL() const {
253 return url;
254 }
255
262 bool getUseCaches() const {
263 return useCaches;
264 }
265
276 void setUseCaches(bool newValue);
277
283 int getConnectTimeout() const;
284
296 void setConnectTimeout(int timeout);
297
304 int getReadTimeout() const;
305
317 void setReadTimeout(int timeout);
318
325 virtual std::string toString() const {
326 return std::string("URLConnection:") + url.toString();
327 }
328
339 virtual std::string getHeaderField(int pos DECAF_UNUSED) const {
340 return "";
341 }
342
353 virtual std::string getHeaderField(const std::string& key DECAF_UNUSED) const {
354 return "";
355 }
356
368 long long getHeaderFieldDate(const std::string& field, long long defaultValue) const;
369
381 int getHeaderFieldInt(const std::string& field, int defaultValue) const;
382
389 long long getLastModified() const;
390
402 __FILE__, __LINE__, "Does not support writing to the input stream");
403 }
404
416 __FILE__, __LINE__, "Does not support writing to the output stream");
417 }
418
426 long long getIfModifiedSince() const {
427 return ifModifiedSince;
428 }
429
441 void setIfModifiedSince(long long newValue);
442
443 public:
444
451 return defaultAllowUserInteraction;
452 }
453
461 static void setDefaultAllowUserInteraction(bool allows) {
462 defaultAllowUserInteraction = allows;
463 }
464
465 };
466
467}}
468
469#endif /* _DECAF_NET_URLCONNECTION_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
Base interface for any class that wants to represent an output stream of bytes.
Definition OutputStream.h:39
bool doOutput
Specifies whether this URLConnection allows sending data.
Definition URLConnection.h:76
bool allowUserInteraction
Specifies whether this URLConnection allows user interaction as it is needed for authentication purpo...
Definition URLConnection.h:87
void setConnectTimeout(int timeout)
Sets the timeout value in milliseconds for establishing the connection to the resource pointed by thi...
long long getHeaderFieldDate(const std::string &field, long long defaultValue) const
Gets the specified header value as a date in milliseconds since January 1, 1970 GMT.
long getExpiration() const
Gets the timestamp when this response will be expired in milliseconds since January 1,...
Definition URLConnection.h:243
bool getUseCaches() const
Gets the value of the flag which specifies whether this URLConnection allows to use caches.
Definition URLConnection.h:262
int getHeaderFieldInt(const std::string &field, int defaultValue) const
Gets the specified header value as a number.
virtual std::string toString() const
Returns the string representation containing the name of this class and the URL.
Definition URLConnection.h:325
virtual decaf::io::OutputStream * getOutputStream()
Gets an OutputStream for writing data to this URLConnection.
Definition URLConnection.h:414
virtual void connect()=0
Establishes the connection to the earlier configured resource.
void setDoOutput(bool newValue)
Sets the flag indicating whether this URLConnection allows output.
void setDoInput(bool newValue)
Sets the flag indicating whether this URLConnection allows input.
URL getURL() const
Gets the URL represented by this URLConnection.
Definition URLConnection.h:252
virtual decaf::io::InputStream * getInputStream()
Gets an InputStream for reading data from the resource pointed by this URLConnection.
Definition URLConnection.h:400
bool getDefaultUseCaches() const
Gets the default setting whether this connection allows using caches.
Definition URLConnection.h:180
long long ifModifiedSince
The data must be modified more recently than this time in milliseconds since January 1,...
Definition URLConnection.h:58
bool getDoInput() const
Gets the value of the option doInput which specifies whether this connection allows to receive data.
Definition URLConnection.h:199
bool connected
Specifies whether this URLConnection is already connected to the remote resource.
Definition URLConnection.h:71
int getConnectTimeout() const
Gets the configured connecting timeout.
void setUseCaches(bool newValue)
Sets the flag indicating whether this connection allows to use caches or not.
void setAllowUserInteraction(bool newValue)
Sets the flag indicating whether this connection allows user interaction or not.
int getContentLength() const
Gets the content length in bytes specified by the response header field 'content-length' or '-1' if t...
Definition URLConnection.h:150
bool doInput
Specifies whether this URLConnection allows receiving data.
Definition URLConnection.h:81
static void setDefaultAllowUserInteraction(bool allows)
Sets the default value for the flag indicating whether this connection allows user interaction or not...
Definition URLConnection.h:461
static bool getDefaultAllowUserInteraction()
Gets the default setting whether this connection allows user interaction.
Definition URLConnection.h:450
bool getAllowUserInteraction() const
Gets the option value which indicates whether user interaction is allowed on this URLConnection.
Definition URLConnection.h:118
long long getLastModified() const
Gets the value of the response header field 'last-modified' or zero if this value is not set.
std::string getContentType() const
Gets the MIME-type of the content specified by the response header field 'content-type' or empty stri...
Definition URLConnection.h:160
virtual std::string getHeaderField(const std::string &key DECAF_UNUSED) const
Gets the value of the header field specified by key or empty string if there is no field with this na...
Definition URLConnection.h:353
void setIfModifiedSince(long long newValue)
Sets the point of time since when the data must be modified to be transmitted.
virtual std::string getHeaderField(int pos DECAF_UNUSED) const
Gets the header value at the field position pos or empty string if the header has fewer than pos fiel...
Definition URLConnection.h:339
URLConnection(const URL &url)
void setDefaultUseCaches(bool newValue)
Sets the default value for the flag indicating whether this connection allows to use caches.
long long getIfModifiedSince() const
Gets the point of time since when the data must be modified to be transmitted.
Definition URLConnection.h:426
bool getDoOutput() const
Gets the value of the option doOutput which specifies whether this connection allows to send data.
Definition URLConnection.h:221
std::string getContentEncoding() const
Gets the content encoding type specified by the response header field content-encoding or empty strin...
Definition URLConnection.h:140
void setReadTimeout(int timeout)
Sets the timeout value in milliseconds for reading from the input stream of an established connection...
long long getDate() const
Gets the timestamp when this response has been sent as a date in milliseconds since January 1,...
Definition URLConnection.h:171
URL url
Definition URLConnection.h:52
int getReadTimeout() const
Gets the configured timeout for reading from the input stream of an established connection to the res...
bool useCaches
Specifies whether the using of caches is enabled or the data has to be recent for every request.
Definition URLConnection.h:64
Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.
Definition URL.h:118
Definition UnknownServiceException.h:27
#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