| 250 | } |
| 251 | |
| 252 | SC::Result SC::HttpTestClient::sendRaw(AsyncEventLoop& loop, StringSpan url, StringSpan request) |
| 253 | { |
| 254 | bodyDelay = {}; |
| 255 | eventLoop = &loop; |
| 256 | |
| 257 | uint16_t port; |
| 258 | HttpURLParser urlParser; |
| 259 | SC_TRY(urlParser.parse(url)); |
| 260 | SC_TRY_MSG(urlParser.protocol == "http", "Invalid protocol"); |
| 261 | char buffer[256]; |
| 262 | Span<char> ipAddress = {buffer}; |
| 263 | SC_TRY(SocketDNS::resolveDNS(urlParser.hostname, ipAddress)) |
| 264 | port = urlParser.port; |
| 265 | SocketIPAddress localHost; |
| 266 | SC_TRY(localHost.fromAddressPort({ipAddress, true, StringEncoding::Ascii}, port)); |
| 267 | SC_TRY(eventLoop->createAsyncTCPSocket(localHost.getAddressFamily(), clientSocket)); |
| 268 | |
| 269 | { |
| 270 | GrowableBuffer<decltype(content)> gb = {content}; |
| 271 | |
| 272 | HttpStringAppend& sb = static_cast<HttpStringAppend&>(static_cast<IGrowableBuffer&>(gb)); |
| 273 | sb.clear(); |
| 274 | SC_TRY(sb.append(request)); |
| 275 | headerBytes = content.size(); |
| 276 | } |
| 277 | |
| 278 | connectAsync.callback.bind<HttpTestClient, &HttpTestClient::startSendingHeaders>(*this); |
| 279 | parser = {}; |
| 280 | parser.type = HttpParser::Type::Response; |
| 281 | receivedBytes = 0; |
| 282 | parsedBytes = 0; |
| 283 | contentLen = 0; |
| 284 | headersReceived = false; |
| 285 | responseHasNoBody = false; |
| 286 | keepConnectionOpen = false; |
| 287 | hasActiveConnection = false; |
| 288 | return connectAsync.start(*eventLoop, clientSocket, localHost); |
| 289 | } |
| 290 | |
| 291 | SC::StringSpan SC::HttpTestClient::getResponse() const |
| 292 | { |
no test coverage detected