[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[PATCH] Add date header parsing and error handling for HttpServletImpl.cpp
From: Sergey Jukov <sergey@total-knowledge.com>
---
ChangeLog | 3 +++
src/container/HttpServletRequestImpl.cpp | 19 +++++++------------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 84d7944..3dbe8c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2006.13.08 Sergey Jukov <sergey@total-knowledge>
+- Fix date header parsing issue in HttpServletImpl.cpp, add exception for
+date header parsing
2006.09.08 Sergey Jukov <sergey@total-knowledge>
- Fix extra path issue in HttpServletImpl.cpp
diff --git a/src/container/HttpServletRequestImpl.cpp b/src/container/HttpServletRequestImpl.cpp
index be8f9d9..2f8b73a 100644
--- a/src/container/HttpServletRequestImpl.cpp
+++ b/src/container/HttpServletRequestImpl.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya A. Volynets-Evenbakh *
+ * Copyright (C) 2004-2006 by Ilya A. Volynets-Evenbakh *
* ilya@total-knowledge.com *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -76,8 +76,6 @@ HttpServletRequestImpl::~HttpServletRequ
void container::HttpServletRequestImpl::getHeaders()
{
//Use stringstream here to parse...
-
-
std::string line;
getline(inputStream,line);
std::string::size_type i=line.find(' ');
@@ -87,13 +85,11 @@ void container::HttpServletRequestImpl::
std::transform(method.begin(),method.end(),method.begin(),util::ToUpper());
std::string::size_type j=++i;
i=line.find(' ',i);
-
if(i==std::string::npos)
return;
uri.assign(line, j, i-j);
protocol.assign(line, i+1, line.length()-i-1);
i=uri.find("://");
-
if(i==std::string::npos)
scheme="http";
else {
@@ -101,14 +97,14 @@ void container::HttpServletRequestImpl::
uri=uri.substr(i+3);
}
i=uri.find('?');
-
if(i!=std::string::npos){
queryString.assign(uri.substr(i+1));
uri.erase(i);
}
- i=uri.find(servletName);
+ std::string servPath(getServletPath() + '/');
+ i=uri.find(servPath);
if(i!=std::string::npos){
- pathInfo=uri.substr(i + servletName.length());
+ pathInfo=uri.substr(i + servPath.length());
}
std::transform(scheme.begin(),scheme.end(),scheme.begin(),util::ToLower());
serverPort=80;
@@ -574,11 +570,11 @@ long HttpServletRequestImpl::getDateHea
if(hval.empty())
return -1;
struct tm out;
- if(strptime(hval.c_str(), "%a, %d %m %Y %H:%M:%S GMT", &out) ||
+ if(strptime(hval.c_str(), "%a, %d %b %Y %H:%M:%S GMT", &out) ||
strptime(hval.c_str(), "%A, %d-%m-%y %H:%M:%S GMT", &out) ||
strptime(hval.c_str(), "%a %m %d %H:%M:%S %Y GMT", &out))
return mktime(&out);
- return -1;
+ throw servlet::ServletException("IllegalArgumentException");
}
std::string HttpServletRequestImpl::getHeader(const std::string& name) const
{
@@ -646,8 +642,7 @@ std::string HttpServletRequestImpl::get
}
std::string HttpServletRequestImpl::getServletPath() const
{
- return ctx->getServletContextName() + '/' + servletName;
-
+ return ctx->getServletContextName() + '/' + servletName;
}
bool HttpServletRequestImpl::isRequestedSessionIdValid() const
{
--
1.4.2