mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 09:16:05 +03:00
parent
fff7b1dcbd
commit
e8f5a3b44e
2 changed files with 24 additions and 7 deletions
|
@ -123,14 +123,30 @@ void Connection::read()
|
|||
{
|
||||
const Environment env {m_socket->localAddress(), m_socket->localPort(), m_socket->peerAddress(), m_socket->peerPort()};
|
||||
|
||||
Response resp = m_requestHandler->processRequest(result.request, env);
|
||||
if (result.request.method == HEADER_REQUEST_METHOD_HEAD)
|
||||
{
|
||||
Request getRequest = result.request;
|
||||
getRequest.method = HEADER_REQUEST_METHOD_GET;
|
||||
|
||||
if (acceptsGzipEncoding(result.request.headers[u"accept-encoding"_s]))
|
||||
resp.headers[HEADER_CONTENT_ENCODING] = u"gzip"_s;
|
||||
Response resp = m_requestHandler->processRequest(getRequest, env);
|
||||
|
||||
resp.headers[HEADER_CONNECTION] = u"keep-alive"_s;
|
||||
resp.headers[HEADER_CONNECTION] = u"keep-alive"_s;
|
||||
resp.headers[HEADER_CONTENT_LENGTH] = QString::number(resp.content.length());
|
||||
resp.content.clear();
|
||||
|
||||
sendResponse(resp);
|
||||
}
|
||||
else
|
||||
{
|
||||
Response resp = m_requestHandler->processRequest(result.request, env);
|
||||
|
||||
if (acceptsGzipEncoding(result.request.headers.value(u"accept-encoding"_s)))
|
||||
resp.headers[HEADER_CONTENT_ENCODING] = u"gzip"_s;
|
||||
resp.headers[HEADER_CONNECTION] = u"keep-alive"_s;
|
||||
|
||||
sendResponse(resp);
|
||||
}
|
||||
|
||||
sendResponse(resp);
|
||||
m_receivedData.remove(0, result.frameSize);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -38,8 +38,9 @@ QByteArray Http::toByteArray(Response response)
|
|||
{
|
||||
compressContent(response);
|
||||
|
||||
response.headers[HEADER_CONTENT_LENGTH] = QString::number(response.content.length());
|
||||
response.headers[HEADER_DATE] = httpDate();
|
||||
if (QString &value = response.headers[HEADER_CONTENT_LENGTH]; value.isEmpty())
|
||||
value = QString::number(response.content.length());
|
||||
|
||||
QByteArray buf;
|
||||
buf.reserve(1024 + response.content.length());
|
||||
|
@ -63,7 +64,7 @@ QByteArray Http::toByteArray(Response response)
|
|||
// the first empty line
|
||||
buf += CRLF;
|
||||
|
||||
// message body // TODO: support HEAD request
|
||||
// message body
|
||||
buf += response.content;
|
||||
|
||||
return buf;
|
||||
|
|
Loading…
Reference in a new issue