MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / request

Method request

Sources/Dependencies/ixwebsocket/IXHttpClient.cpp:124–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122 }
123
124 HttpResponsePtr HttpClient::request(const std::string& url,
125 const std::string& verb,
126 const std::string& body,
127 HttpRequestArgsPtr args,
128 int redirects)
129 {
130 // We only have one socket connection, so we cannot
131 // make multiple requests concurrently.
132 std::lock_guard<std::recursive_mutex> lock(_mutex);
133
134 uint64_t uploadSize = 0;
135 uint64_t downloadSize = 0;
136 int code = 0;
137 WebSocketHttpHeaders headers;
138 std::string payload;
139 std::string description;
140
141 std::string protocol, host, path, query;
142 int port;
143 bool isProtocolDefaultPort;
144
145 if (!UrlParser::parse(url, protocol, host, path, query, port, isProtocolDefaultPort))
146 {
147 std::stringstream ss;
148 ss << "Cannot parse url: " << url;
149 return std::make_shared<HttpResponse>(code,
150 description,
151 HttpErrorCode::UrlMalformed,
152 headers,
153 payload,
154 ss.str(),
155 uploadSize,
156 downloadSize);
157 }
158
159 bool tls = protocol == "https";
160 std::string errorMsg;
161 _socket = createSocket(tls, -1, errorMsg, _tlsOptions);
162
163 if (!_socket)
164 {
165 return std::make_shared<HttpResponse>(code,
166 description,
167 HttpErrorCode::CannotCreateSocket,
168 headers,
169 payload,
170 errorMsg,
171 uploadSize,
172 downloadSize);
173 }
174
175 // Build request string
176 std::stringstream ss;
177 ss << verb << " " << path << " HTTP/1.1\r\n";
178 ss << "Host: " << host;
179 if (!isProtocolDefaultPort)
180 {
181 ss << ":" << port;

Callers

nothing calls this directly

Calls 15

createSocketFunction · 0.85
userAgentFunction · 0.85
parseHttpHeadersFunction · 0.85
gzipDecompressFunction · 0.85
gzipCompressFunction · 0.85
writeBytesMethod · 0.80
readLineMethod · 0.80
c_strMethod · 0.80
readBytesMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected