Style fixes to HttpForm
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_HTTP_FORM_H_
|
||||
@@ -125,8 +125,7 @@ public:
|
||||
bool HasField(const BString& name) const;
|
||||
|
||||
// Form retrieve
|
||||
BString GetMultipartHeader(const BString& fieldName)
|
||||
const;
|
||||
BString GetMultipartHeader(const BString& fieldName) const;
|
||||
form_content_type GetType(const BString& fieldname) const;
|
||||
|
||||
// Form informations
|
||||
@@ -145,11 +144,9 @@ public:
|
||||
BHttpFormData& operator[](const BString& name);
|
||||
|
||||
private:
|
||||
void _ExtractNameValuePair(const BString& string,
|
||||
int32* index);
|
||||
void _ExtractNameValuePair(const BString& string, int32* index);
|
||||
void _GenerateMultipartBoundary();
|
||||
BString _GetMultipartHeader(
|
||||
const BHttpFormData* element) const;
|
||||
BString _GetMultipartHeader(const BHttpFormData* element) const;
|
||||
form_content_type _GetType(FormStorage::const_iterator it) const;
|
||||
void _Erase(FormStorage::iterator it);
|
||||
|
||||
@@ -162,7 +159,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
class BHttpForm::Iterator {
|
||||
public:
|
||||
Iterator(const Iterator& other);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* Authors:
|
||||
@@ -7,22 +7,24 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <HttpForm.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
#include <File.h>
|
||||
#include <HttpForm.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <TypeConstants.h>
|
||||
#include <Url.h>
|
||||
|
||||
|
||||
static int32 kBoundaryRandomSize = 16;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// #pragma mark -- BHttpFormData
|
||||
// #pragma mark - BHttpFormData
|
||||
|
||||
|
||||
BHttpFormData::BHttpFormData()
|
||||
@@ -93,7 +95,7 @@ BHttpFormData::~BHttpFormData()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Retrieve data informations
|
||||
// #pragma mark - Retrieve data informations
|
||||
|
||||
|
||||
bool
|
||||
@@ -169,7 +171,9 @@ BHttpFormData::Type() const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Change behavior
|
||||
// #pragma mark - Change behavior
|
||||
|
||||
|
||||
status_t
|
||||
BHttpFormData::MarkAsFile(const BString& filename, const BString& mimeType)
|
||||
{
|
||||
@@ -232,23 +236,26 @@ BHttpFormData::operator=(const BHttpFormData& other)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -- BHttpForm
|
||||
// #pragma mark - BHttpForm
|
||||
|
||||
|
||||
BHttpForm::BHttpForm()
|
||||
: fType(B_HTTP_FORM_URL_ENCODED)
|
||||
:
|
||||
fType(B_HTTP_FORM_URL_ENCODED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BHttpForm::BHttpForm(const BHttpForm&)
|
||||
: fType(B_HTTP_FORM_URL_ENCODED)
|
||||
BHttpForm::BHttpForm(const BHttpForm& other)
|
||||
:
|
||||
fType(B_HTTP_FORM_URL_ENCODED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BHttpForm::BHttpForm(const BString& formString)
|
||||
: fType(B_HTTP_FORM_URL_ENCODED)
|
||||
:
|
||||
fType(B_HTTP_FORM_URL_ENCODED)
|
||||
{
|
||||
ParseString(formString);
|
||||
}
|
||||
@@ -260,7 +267,7 @@ BHttpForm::~BHttpForm()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Form string parsing
|
||||
// #pragma mark - Form string parsing
|
||||
|
||||
|
||||
void
|
||||
@@ -268,9 +275,8 @@ BHttpForm::ParseString(const BString& formString)
|
||||
{
|
||||
int32 index = 0;
|
||||
|
||||
while (index < formString.Length()) {
|
||||
while (index < formString.Length())
|
||||
_ExtractNameValuePair(formString, &index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -338,8 +344,8 @@ BHttpForm::RawData() const
|
||||
result.Append(readBuffer, readSize);
|
||||
readSize = upFile.Read(readBuffer, 1024);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_HTTPFORM_BUFFER:
|
||||
result.Append(
|
||||
@@ -358,7 +364,7 @@ BHttpForm::RawData() const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Form add
|
||||
// #pragma mark - Form add
|
||||
|
||||
|
||||
status_t
|
||||
@@ -428,7 +434,7 @@ BHttpForm::AddBufferCopy(const BString& fieldName, const void* buffer,
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Mark a field as a filename
|
||||
// #pragma mark - Mark a field as a filename
|
||||
|
||||
|
||||
void
|
||||
@@ -465,7 +471,7 @@ BHttpForm::UnmarkAsFile(const BString& fieldName)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Change form type
|
||||
// #pragma mark - Change form type
|
||||
|
||||
|
||||
void
|
||||
@@ -478,7 +484,7 @@ BHttpForm::SetFormType(form_type type)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Form test
|
||||
// #pragma mark - Form test
|
||||
|
||||
|
||||
bool
|
||||
@@ -488,7 +494,7 @@ BHttpForm::HasField(const BString& name) const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Form retrieve
|
||||
// #pragma mark - Form retrieve
|
||||
|
||||
|
||||
BString
|
||||
@@ -552,8 +558,8 @@ BHttpForm::ContentLength() const
|
||||
BFile upFile(c->File().Path(), B_READ_ONLY);
|
||||
upFile.Seek(0, SEEK_END);
|
||||
contentLength += upFile.Position();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_HTTPFORM_BUFFER:
|
||||
contentLength += c->BufferSize();
|
||||
@@ -579,7 +585,7 @@ BHttpForm::GetIterator()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Form clear
|
||||
// #pragma mark - Form clear
|
||||
|
||||
|
||||
void
|
||||
@@ -589,7 +595,7 @@ BHttpForm::Clear()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Overloaded operators
|
||||
// #pragma mark - Overloaded operators
|
||||
|
||||
|
||||
BHttpFormData&
|
||||
@@ -651,7 +657,7 @@ BHttpForm::_GenerateMultipartBoundary()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark Field information access by std iterator
|
||||
// #pragma mark - Field information access by std iterator
|
||||
|
||||
|
||||
BString
|
||||
@@ -679,8 +685,9 @@ BHttpForm::_GetMultipartHeader(const BHttpFormData* element) const
|
||||
result << tempMime;
|
||||
else
|
||||
result << "application/octet-stream";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case B_HTTPFORM_STRING:
|
||||
case B_HTTPFORM_BUFFER:
|
||||
@@ -696,15 +703,17 @@ BHttpForm::_GetMultipartHeader(const BHttpFormData* element) const
|
||||
}
|
||||
|
||||
result << "\r\n\r\n";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -- Iterator
|
||||
// #pragma mark - Iterator
|
||||
|
||||
|
||||
BHttpForm::Iterator::Iterator(BHttpForm* form)
|
||||
: fElement(NULL)
|
||||
:
|
||||
fElement(NULL)
|
||||
{
|
||||
fForm = form;
|
||||
fStdIterator = form->fFields.begin();
|
||||
|
||||
Reference in New Issue
Block a user