MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / open

Method open

base/poco/Net/src/HTTPStreamFactory.cpp:68–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68std::istream* HTTPStreamFactory::open(const URI& uri)
69{
70 poco_assert (uri.getScheme() == "http");
71
72 URI resolvedURI(uri);
73 URI proxyUri;
74 HTTPClientSession* pSession = 0;
75 HTTPResponse res;
76 bool retry = false;
77 bool authorize = false;
78 std::string username;
79 std::string password;
80
81 try
82 {
83 do
84 {
85 if (!pSession)
86 {
87 pSession = new HTTPClientSession(resolvedURI.getHost(), resolvedURI.getPort());
88
89 if (proxyUri.empty())
90 {
91 if (!_proxyHost.empty())
92 {
93 pSession->setProxy(_proxyHost, _proxyPort);
94 pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
95 }
96 }
97 else
98 {
99 pSession->setProxy(proxyUri.getHost(), proxyUri.getPort());
100 if (!_proxyUsername.empty())
101 {
102 pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
103 }
104 }
105 }
106
107 std::string path = resolvedURI.getPathAndQuery();
108 if (path.empty()) path = "/";
109 HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
110
111 if (authorize)
112 {
113 HTTPCredentials::extractCredentials(uri, username, password);
114 HTTPCredentials cred(username, password);
115 cred.authenticate(req, res);
116 }
117
118 req.set("User-Agent", Poco::format("poco/%d.%d.%d",
119 (POCO_VERSION >> 24) & 0xFF,
120 (POCO_VERSION >> 16) & 0xFF,
121 (POCO_VERSION >> 8) & 0xFF));
122 req.set("Accept", "*/*");
123
124 pSession->sendRequest(req);
125 std::istream& rs = pSession->receiveResponse(res);

Callers

nothing calls this directly

Calls 15

HTTPExceptionClass · 0.85
getHostMethod · 0.80
getPathAndQueryMethod · 0.80
setUserInfoMethod · 0.80
formatFunction · 0.50
getPortMethod · 0.45
emptyMethod · 0.45
setProxyMethod · 0.45
setProxyCredentialsMethod · 0.45
authenticateMethod · 0.45
setMethod · 0.45
sendRequestMethod · 0.45

Tested by

no test coverage detected