Style fixes to HttpRequest
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010 Haiku Inc. All rights reserved.
|
* Copyright 2010-2013 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _B_URL_PROTOCOL_HTTP_H_
|
#ifndef _B_URL_PROTOCOL_HTTP_H_
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
|
||||||
#include <HttpForm.h>
|
#include <HttpForm.h>
|
||||||
#include <HttpHeaders.h>
|
#include <HttpHeaders.h>
|
||||||
#include <HttpResult.h>
|
#include <HttpResult.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2011 Haiku Inc. All rights reserved.
|
* Copyright 2010-2013 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,16 +8,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <HttpRequest.h>
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Socket.h>
|
#include <Socket.h>
|
||||||
#include <SecureSocket.h>
|
#include <SecureSocket.h>
|
||||||
#include <HttpRequest.h>
|
|
||||||
|
|
||||||
|
|
||||||
static const int32 kHttpBufferSize = 4096;
|
static const int32 kHttpBufferSize = 4096;
|
||||||
@@ -274,7 +277,7 @@ BHttpRequest::_ResetOptions()
|
|||||||
fOptAutoReferer = true;
|
fOptAutoReferer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
status_t
|
status_t
|
||||||
BHttpRequest::_ProtocolLoop()
|
BHttpRequest::_ProtocolLoop()
|
||||||
{
|
{
|
||||||
@@ -349,8 +352,7 @@ BHttpRequest::_ProtocolLoop()
|
|||||||
= &fContext->GetAuthentication(fUrl);
|
= &fContext->GetAuthentication(fUrl);
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
if (authentication->Method() == B_HTTP_AUTHENTICATION_NONE)
|
if (authentication->Method() == B_HTTP_AUTHENTICATION_NONE) {
|
||||||
{
|
|
||||||
// There is no authentication context for this
|
// There is no authentication context for this
|
||||||
// url yet, so let's create one.
|
// url yet, so let's create one.
|
||||||
authentication = new BHttpAuthentication();
|
authentication = new BHttpAuthentication();
|
||||||
@@ -511,10 +513,10 @@ BHttpRequest::_MakeRequest()
|
|||||||
ssize_t read = fOptInputData->Read(outputTempBuffer,
|
ssize_t read = fOptInputData->Read(outputTempBuffer,
|
||||||
sizeof(outputTempBuffer));
|
sizeof(outputTempBuffer));
|
||||||
|
|
||||||
if(read <= 0) break;
|
if (read <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
if (fOptInputDataSize < 0)
|
if (fOptInputDataSize < 0) {
|
||||||
{
|
|
||||||
// Chunked transfer
|
// Chunked transfer
|
||||||
char hexSize[16];
|
char hexSize[16];
|
||||||
size_t hexLength = sprintf(hexSize, "%ld", read);
|
size_t hexLength = sprintf(hexSize, "%ld", read);
|
||||||
@@ -564,8 +566,7 @@ BHttpRequest::_MakeRequest()
|
|||||||
receiveEnd = true;
|
receiveEnd = true;
|
||||||
|
|
||||||
fInputBuffer.AppendData(chunk.Data(), bytesRead);
|
fInputBuffer.AppendData(chunk.Data(), bytesRead);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
bytesRead = 0;
|
bytesRead = 0;
|
||||||
|
|
||||||
if (fRequestStatus < kRequestStatusReceived) {
|
if (fRequestStatus < kRequestStatusReceived) {
|
||||||
@@ -651,9 +652,8 @@ BHttpRequest::_MakeRequest()
|
|||||||
|
|
||||||
// A chunk of 0 bytes indicates the end of the chunked
|
// A chunk of 0 bytes indicates the end of the chunked
|
||||||
// transfer
|
// transfer
|
||||||
if (bytesRead == 0) {
|
if (bytesRead == 0)
|
||||||
receiveEnd = true;
|
receiveEnd = true;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bytesRead = fInputBuffer.Size();
|
bytesRead = fInputBuffer.Size();
|
||||||
|
|
||||||
@@ -855,14 +855,12 @@ BHttpRequest::_AddHeaders()
|
|||||||
fOutputHeaders.AddHeader("Content-Length",
|
fOutputHeaders.AddHeader("Content-Length",
|
||||||
fOptPostFields->ContentLength());
|
fOptPostFields->ContentLength());
|
||||||
} else if (fOptInputData != NULL
|
} else if (fOptInputData != NULL
|
||||||
&& (fRequestMethod == B_HTTP_POST || fRequestMethod == B_HTTP_PUT))
|
&& (fRequestMethod == B_HTTP_POST || fRequestMethod == B_HTTP_PUT)) {
|
||||||
{
|
if (fOptInputDataSize >= 0)
|
||||||
if(fOptInputDataSize >= 0) {
|
|
||||||
fOutputHeaders.AddHeader("Content-Length", fOptInputDataSize);
|
fOutputHeaders.AddHeader("Content-Length", fOptInputDataSize);
|
||||||
} else {
|
else
|
||||||
fOutputHeaders.AddHeader("Transfer-Encoding", "chunked");
|
fOutputHeaders.AddHeader("Transfer-Encoding", "chunked");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Optional headers specified by the user
|
// Optional headers specified by the user
|
||||||
if (fOptHeaders != NULL) {
|
if (fOptHeaders != NULL) {
|
||||||
@@ -901,9 +899,10 @@ BHttpRequest::_AddHeaders()
|
|||||||
|
|
||||||
// Write output headers to output stream
|
// Write output headers to output stream
|
||||||
for (int32 headerIndex = 0; headerIndex < fOutputHeaders.CountHeaders();
|
for (int32 headerIndex = 0; headerIndex < fOutputHeaders.CountHeaders();
|
||||||
headerIndex++)
|
headerIndex++) {
|
||||||
_AddOutputBufferLine(fOutputHeaders.HeaderAt(headerIndex).Header());
|
_AddOutputBufferLine(fOutputHeaders.HeaderAt(headerIndex).Header());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user