Beispiel #1
0
void Pillow::HttpClient::sendRequest()
{
	if (!responsePending()) return;

	if (_hostHeaderValue.isEmpty())
	{
        _hostHeaderValue = _request.url.host(QUrl::FullyEncoded).toUtf8();
		if (_request.url.port(80) != 80)
		{
			_hostHeaderValue.append(':');
			Pillow::ByteArrayHelpers::appendNumber<int, 10>(_hostHeaderValue, _request.url.port(80));
		}
	}

    QByteArray uri = _request.url.path(QUrl::FullyEncoded).toUtf8();
    const QByteArray query = _request.url.query(QUrl::FullyEncoded).toUtf8();
	if (!query.isEmpty()) uri.append('?').append(query);

	Pillow::HttpHeaderCollection headers;
	headers.reserve(_request.headers.size() + 1);
	headers << Pillow::HttpHeader(Pillow::HttpClientTokens::hostToken, _hostHeaderValue);
	for (int i = 0, iE = _request.headers.size(); i < iE; ++i)
		headers << _request.headers.at(i);

	_requestWriter.write(_request.method, uri, headers, _request.data);
}
Beispiel #2
0
void Pillow::HttpHandlerProxyPipe::sendHeaders()
{
	if (_headersSent || _broken) return;
	_headersSent = true;

	// Headers have not been sent yet. Do so now.
	int statusCode = _proxiedReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
	QList<QPair<QByteArray, QByteArray> > headerList = _proxiedReply->rawHeaderPairs();
	Pillow::HttpHeaderCollection headers; headers.reserve(headerList.size());
	for (int i = 0, iE = headerList.size(); i < iE; ++i)
		headers << headerList.at(i);
	_request->writeHeaders(statusCode, headers);
}
void Pillow::HttpHandlerProxyPipe::sendHeaders()
{
	if (_headersSent || _broken) return;
	_headersSent = true;

	// Headers have not been sent yet. Do so now.
	int statusCode = _proxiedReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
	QList<Pillow::HttpHeader> headerList = _proxiedReply->rawHeaderPairs();
	Pillow::HttpHeaderCollection headers; headers.reserve(headerList.size());
	foreach (const Pillow::HttpHeader& header, headerList)
		headers << header;
	_request->writeHeaders(statusCode, headers);
}