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