Net: near complete merge to 1.4.2

This commit is contained in:
Marian Krivos
2011-09-14 18:20:11 +00:00
parent 56c6a4f758
commit b242f2c8d1
192 changed files with 15545 additions and 2277 deletions

View File

@@ -1,7 +1,7 @@
//
// HTTPRequest.cpp
//
// $Id: //poco/Main/Net/src/HTTPRequest.cpp#14 $
// $Id: //poco/1.4/Net/src/HTTPRequest.cpp#1 $
//
// Library: Net
// Package: HTTP
@@ -35,11 +35,10 @@
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPSession.h"
#include "Poco/Net/NetException.h"
#include "Poco/Net/NameValueCollection.h"
#include "Poco/NumberFormatter.h"
#include <cctype>
#include "Poco/Ascii.h"
using Poco::NumberFormatter;
@@ -118,7 +117,7 @@ void HTTPRequest::setHost(const std::string& host)
void HTTPRequest::setHost(const std::string& host, Poco::UInt16 port)
{
std::string value(host);
if (port != HTTPSession::HTTP_PORT)
if (port != 80 && port != 443)
{
value.append(":");
NumberFormatter::append(value, port);
@@ -175,9 +174,9 @@ void HTTPRequest::getCredentials(std::string& scheme, std::string& authInfo) con
const std::string& auth = get(AUTHORIZATION);
std::string::const_iterator it = auth.begin();
std::string::const_iterator end = auth.end();
while (it != end && std::isspace(*it)) ++it;
while (it != end && !std::isspace(*it)) scheme += *it++;
while (it != end && std::isspace(*it)) ++it;
while (it != end && Poco::Ascii::isSpace(*it)) ++it;
while (it != end && !Poco::Ascii::isSpace(*it)) scheme += *it++;
while (it != end && Poco::Ascii::isSpace(*it)) ++it;
while (it != end) authInfo += *it++;
}
else throw NotAuthenticatedException();
@@ -213,16 +212,16 @@ void HTTPRequest::read(std::istream& istr)
version.reserve(16);
int ch = istr.get();
if (ch == eof) throw NoMessageException();
while (std::isspace(ch)) ch = istr.get();
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
if (ch == eof) throw MessageException("No HTTP request header");
while (!std::isspace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); }
if (!std::isspace(ch)) throw MessageException("HTTP request method invalid or too long");
while (std::isspace(ch)) ch = istr.get();
while (!std::isspace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); }
if (!std::isspace(ch)) throw MessageException("HTTP request URI invalid or too long");
while (std::isspace(ch)) ch = istr.get();
while (!std::isspace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); }
if (!std::isspace(ch)) throw MessageException("Invalid HTTP version string");
while (!Poco::Ascii::isSpace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); }
if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP request method invalid or too long");
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
while (!Poco::Ascii::isSpace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); }
if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP request URI invalid or too long");
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
while (!Poco::Ascii::isSpace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); }
if (!Poco::Ascii::isSpace(ch)) throw MessageException("Invalid HTTP version string");
while (ch != '\n' && ch != eof) { ch = istr.get(); }
HTTPMessage::read(istr);
ch = istr.get();