forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTTPStreamFactory.h
More file actions
92 lines (72 loc) · 2.42 KB
/
HTTPStreamFactory.h
File metadata and controls
92 lines (72 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// HTTPStreamFactory.h
//
// Library: Net
// Package: HTTP
// Module: HTTPStreamFactory
//
// Definition of the HTTPStreamFactory class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Net_HTTPStreamFactory_INCLUDED
#define Net_HTTPStreamFactory_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/HTTPSession.h"
#include "Poco/URIStreamFactory.h"
namespace Poco {
namespace Net {
class Net_API HTTPStreamFactory: public Poco::URIStreamFactory
/// An implementation of the URIStreamFactory interface
/// that handles Hyper-Text Transfer Protocol (http) URIs.
{
public:
HTTPStreamFactory();
/// Creates the HTTPStreamFactory.
HTTPStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort = HTTPSession::HTTP_PORT);
/// Creates the HTTPStreamFactory.
///
/// HTTP connections will use the given proxy.
HTTPStreamFactory(const std::string& proxyHost, Poco::UInt16 proxyPort, const std::string& proxyUsername, const std::string& proxyPassword);
/// Creates the HTTPStreamFactory.
///
/// HTTP connections will use the given proxy and
/// will be authorized against the proxy using Basic authentication
/// with the given proxyUsername and proxyPassword.
virtual ~HTTPStreamFactory();
/// Destroys the HTTPStreamFactory.
virtual std::istream* open(const Poco::URI& uri);
/// Creates and opens a HTTP stream for the given URI.
/// The URI must be a http://... URI.
///
/// Throws a NetException if anything goes wrong.
///
/// Redirect responses are handled and the redirect
/// location is automatically resolved, as long
/// as the redirect location is still accessible
/// via the HTTP protocol. If a redirection to
/// a non http://... URI is received, a
/// UnsupportedRedirectException exception is thrown.
/// The offending URI can then be obtained via the message()
/// method of UnsupportedRedirectException.
static void registerFactory();
/// Registers the HTTPStreamFactory with the
/// default URIStreamOpener instance.
static void unregisterFactory();
/// Unregisters the HTTPStreamFactory with the
/// default URIStreamOpener instance.
private:
enum
{
MAX_REDIRECTS = 10
};
std::string _proxyHost;
Poco::UInt16 _proxyPort;
std::string _proxyUsername;
std::string _proxyPassword;
};
} } // namespace Poco::Net
#endif // Net_HTTPStreamFactory_INCLUDED