fixed various bugs (see SF tracker)

This commit is contained in:
Guenter Obiltschnig
2008-09-16 17:26:28 +00:00
parent 5b26a62961
commit 57762a2cfc
19 changed files with 97 additions and 28 deletions

View File

@@ -166,6 +166,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="..\lib\Poco$(ProjectName)mtd.lib"/>
<Tool
Name="VCMIDLTool"/>
@@ -219,6 +220,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="..\lib\Poco$(ProjectName)mt.lib"/>
<Tool
Name="VCMIDLTool"/>

View File

@@ -258,6 +258,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="..\lib\Poco$(ProjectName)mt.lib"
/>
<Tool
@@ -329,6 +330,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="..\lib\Poco$(ProjectName)mtd.lib"
/>
<Tool

View File

@@ -249,6 +249,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="..\lib\Poco$(ProjectName)mt.lib"
/>
<Tool
@@ -318,6 +319,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="..\lib\Poco$(ProjectName)mtd.lib"
/>
<Tool

View File

@@ -1,7 +1,7 @@
//
// HTTPCookie.h
//
// $Id: //poco/svn/Net/include/Poco/Net/HTTPCookie.h#2 $
// $Id: //poco/1.3/Net/include/Poco/Net/HTTPCookie.h#1 $
//
// Library: Net
// Package: HTTP
@@ -157,6 +157,12 @@ public:
/// Returns the maximum age in seconds for
/// the cookie.
void setHttpOnly(bool flag = true);
/// Sets the HttpOnly flag for the cookie.
bool getHttpOnly() const;
/// Returns true iff the cookie's HttpOnly flag is set.
std::string toString() const;
/// Returns a string representation of the cookie,
/// suitable for use in a Set-Cookie header.
@@ -170,6 +176,7 @@ private:
std::string _path;
bool _secure;
int _maxAge;
bool _httpOnly;
};
@@ -224,6 +231,12 @@ inline int HTTPCookie::getMaxAge() const
}
inline bool HTTPCookie::getHttpOnly() const
{
return _httpOnly;
}
} } // namespace Poco::Net

View File

@@ -124,6 +124,7 @@ void HTMLForm::addPart(const std::string& name, PartSource* pSource)
void HTMLForm::load(const HTTPRequest& request, std::istream& requestBody, PartHandler& handler)
{
clear();
if (request.getMethod() == HTTPRequest::HTTP_POST)
{
std::string mediaType;

View File

@@ -1,7 +1,7 @@
//
// HTTPCookie.cpp
//
// $Id: //poco/svn/Net/src/HTTPCookie.cpp#2 $
// $Id: //poco/1.3/Net/src/HTTPCookie.cpp#2 $
//
// Library: Net
// Package: HTTP
@@ -63,7 +63,8 @@ namespace Net {
HTTPCookie::HTTPCookie():
_version(0),
_secure(false),
_maxAge(-1)
_maxAge(-1),
_httpOnly(false)
{
}
@@ -72,7 +73,8 @@ HTTPCookie::HTTPCookie(const std::string& name):
_version(0),
_name(name),
_secure(false),
_maxAge(-1)
_maxAge(-1),
_httpOnly(false)
{
}
@@ -80,7 +82,8 @@ HTTPCookie::HTTPCookie(const std::string& name):
HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
_version(0),
_secure(false),
_maxAge(-1)
_maxAge(-1),
_httpOnly(false)
{
for (NameValueCollection::ConstIterator it = nvc.begin(); it != nvc.end(); ++it)
{
@@ -117,6 +120,10 @@ HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
{
setVersion(NumberParser::parse(value));
}
else if (icompare(name, "HttpOnly") == 0)
{
setHttpOnly(true);
}
else
{
setName(name);
@@ -131,7 +138,8 @@ HTTPCookie::HTTPCookie(const std::string& name, const std::string& value):
_name(name),
_value(value),
_secure(false),
_maxAge(-1)
_maxAge(-1),
_httpOnly(false)
{
}
@@ -144,7 +152,8 @@ HTTPCookie::HTTPCookie(const HTTPCookie& cookie):
_domain(cookie._domain),
_path(cookie._path),
_secure(cookie._secure),
_maxAge(cookie._maxAge)
_maxAge(cookie._maxAge),
_httpOnly(cookie._httpOnly)
{
}
@@ -158,14 +167,15 @@ HTTPCookie& HTTPCookie::operator = (const HTTPCookie& cookie)
{
if (&cookie != this)
{
_version = cookie._version;
_name = cookie._name;
_value = cookie._value;
_comment = cookie._comment;
_domain = cookie._domain;
_path = cookie._path;
_secure = cookie._secure;
_maxAge = cookie._maxAge;
_version = cookie._version;
_name = cookie._name;
_value = cookie._value;
_comment = cookie._comment;
_domain = cookie._domain;
_path = cookie._path;
_secure = cookie._secure;
_maxAge = cookie._maxAge;
_httpOnly = cookie._httpOnly;
}
return *this;
}
@@ -219,6 +229,12 @@ void HTTPCookie::setMaxAge(int maxAge)
}
void HTTPCookie::setHttpOnly(bool flag)
{
_httpOnly = flag;
}
std::string HTTPCookie::toString() const
{
std::string result(_name);
@@ -248,6 +264,10 @@ std::string HTTPCookie::toString() const
{
result.append("; secure");
}
if (_httpOnly)
{
result.append("; HttpOnly");
}
}
else
{
@@ -283,6 +303,10 @@ std::string HTTPCookie::toString() const
{
result.append("; secure");
}
if (_httpOnly)
{
result.append("; HttpOnly");
}
result.append("; Version=\"1\"");
}
return result;

View File

@@ -1,7 +1,7 @@
//
// HTTPCookieTest.cpp
//
// $Id: //poco/svn/Net/testsuite/src/HTTPCookieTest.cpp#2 $
// $Id: //poco/1.3/Net/testsuite/src/HTTPCookieTest.cpp#1 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -63,6 +63,9 @@ void HTTPCookieTest::testCookie()
assert (cookie.toString() == "name=value; domain=appinf.com; path=/");
cookie.setSecure(true);
assert (cookie.toString() == "name=value; domain=appinf.com; path=/; secure");
cookie.setHttpOnly(true);
assert (cookie.toString() == "name=value; domain=appinf.com; path=/; secure; HttpOnly");
cookie.setHttpOnly(false);
cookie.setVersion(1);
assert (cookie.toString() == "name=\"value\"; Comment=\"comment\"; Domain=\"appinf.com\"; Path=\"/\"; secure; Version=\"1\"");
@@ -70,6 +73,9 @@ void HTTPCookieTest::testCookie()
cookie.setSecure(false);
cookie.setMaxAge(100);
assert (cookie.toString() == "name=\"value\"; Comment=\"comment\"; Domain=\"appinf.com\"; Path=\"/\"; Max-Age=\"100\"; Version=\"1\"");
cookie.setHttpOnly(true);
assert (cookie.toString() == "name=\"value\"; Comment=\"comment\"; Domain=\"appinf.com\"; Path=\"/\"; Max-Age=\"100\"; HttpOnly; Version=\"1\"");
}