| 194 | } |
| 195 | |
| 196 | int QHttpConnection::HeadersComplete(http_parser *parser) |
| 197 | { |
| 198 | QHttpConnection *theConnection = static_cast<QHttpConnection *>(parser->data); |
| 199 | Q_ASSERT(theConnection->m_request); |
| 200 | |
| 201 | /** set method **/ |
| 202 | theConnection->m_request->setMethod(static_cast<QHttpRequest::HttpMethod>(parser->method)); |
| 203 | |
| 204 | /** set version **/ |
| 205 | theConnection->m_request->setVersion( |
| 206 | QString::fromUtf8("%1.%2").arg(parser->http_major).arg(parser->http_minor)); |
| 207 | |
| 208 | /** get parsed url **/ |
| 209 | struct http_parser_url urlInfo; |
| 210 | int r = http_parser_parse_url(theConnection->m_currentUrl.constData(), |
| 211 | theConnection->m_currentUrl.size(), |
| 212 | parser->method == HTTP_CONNECT, &urlInfo); |
| 213 | Q_ASSERT(r == 0); |
| 214 | Q_UNUSED(r); |
| 215 | |
| 216 | theConnection->m_request->setUrl(createUrl(theConnection->m_currentUrl.constData(), urlInfo)); |
| 217 | |
| 218 | // Insert last remaining header |
| 219 | theConnection->m_currentHeaders[theConnection->m_currentHeaderField.toLower()] = |
| 220 | theConnection->m_currentHeaderValue; |
| 221 | theConnection->m_request->setHeaders(theConnection->m_currentHeaders); |
| 222 | |
| 223 | /** set client information **/ |
| 224 | theConnection->m_request->m_remoteAddress = theConnection->m_socket->peerAddress().toString(); |
| 225 | theConnection->m_request->m_remotePort = theConnection->m_socket->peerPort(); |
| 226 | |
| 227 | QHttpResponse *response = new QHttpResponse(theConnection); |
| 228 | if (parser->http_major < 1 || parser->http_minor < 1) |
| 229 | response->m_keepAlive = false; |
| 230 | |
| 231 | connect(theConnection, SIGNAL(destroyed()), response, SLOT(connectionClosed())); |
| 232 | connect(response, SIGNAL(done()), theConnection, SLOT(responseDone())); |
| 233 | |
| 234 | // we are good to go! |
| 235 | Q_EMIT theConnection->newRequest(theConnection->m_request, response); |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | int QHttpConnection::MessageComplete(http_parser *parser) |
| 240 | { |
nothing calls this directly
no test coverage detected