CPPSERV


Home Projects Jobs Clientele Contact

cppserv


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix date header issue in HttpServletRequestImpl.cpp



I guess I'll start numbering mistakes.
#1 will be "unneeded white space changes"

Sergey wrote:
> ---- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,5 @@
> +2006.12.08        Sergey Jukov <sergey@total-knowledge>
> +- Fix date header parsing issue in HttpServletImpl.cpp
>   
I think you had two changes, no?
> -- 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 by Ilya A. Volynets-Evenbakh                       *
>   
When you change file, extend (C) years, not replace.
i.e. (C) 2004-2006
>   *   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...
> -
> -
>   
#1
>  	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);
> -
>   
#1
>  	if(i==std::string::npos)
>  		return;
>  	uri.assign(line, j, i-j);
>  	protocol.assign(line, i+1, line.length()-i-1);
>  	i=uri.find("://");
> -
>   
#1
>  	if(i==std::string::npos)
>  		scheme="http";
>  	else {
> @@ -101,14 +97,14 @@ void container::HttpServletRequestImpl::
>  		uri=uri.substr(i+3);
>  	}
>  	i=uri.find('?');
> -
>   
#1
>  	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());
>  	}
>   
Something is messed up here. My code already like this.
>  	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 
>  {
>   

-- 
Ilya A. Volynets-Evenbakh
Total Knowledge. CTO
http://www.total-knowledge.com


Authoright © Total Knowledge: 2001-2008