[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Myserver-commit] [2737] Method simplified
From: |
Giuseppe Scrivano |
Subject: |
[Myserver-commit] [2737] Method simplified |
Date: |
Tue, 05 Aug 2008 21:34:50 +0000 |
Revision: 2737
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2737
Author: gscrivano
Date: 2008-08-05 21:34:49 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
Method simplified
Modified Paths:
--------------
trunk/myserver/include/http_request.h
trunk/myserver/src/cgi.cpp
Modified: trunk/myserver/include/http_request.h
===================================================================
--- trunk/myserver/include/http_request.h 2008-08-05 18:34:49 UTC (rev
2736)
+++ trunk/myserver/include/http_request.h 2008-08-05 21:34:49 UTC (rev
2737)
@@ -97,6 +97,11 @@
virtual string* getValue(const char* name, string* out);
virtual string* setValue(const char* name, const char* in);
+ HashMap<string, HttpRequestHeader::Entry*>::Iterator begin(){return
other.begin();}
+ HashMap<string, HttpRequestHeader::Entry*>::Iterator back(){return
other.back();}
+ HashMap<string, HttpRequestHeader::Entry*>::Iterator end(){return
other.end();}
+
+
bool isKeepAlive();
HttpRequestHeader();
Modified: trunk/myserver/src/cgi.cpp
===================================================================
--- trunk/myserver/src/cgi.cpp 2008-08-05 18:34:49 UTC (rev 2736)
+++ trunk/myserver/src/cgi.cpp 2008-08-05 21:34:49 UTC (rev 2737)
@@ -33,6 +33,7 @@
#include <string>
#include <sstream>
+#include <algorithm>
extern "C" {
#ifdef WIN32
@@ -800,121 +801,7 @@
else
memCgi << end_str << "SSL=OFF";
- if(td->request.auth.length())
- {
- memCgi << end_str << "AUTH_TYPE=";
- memCgi << td->request.auth.c_str();
- }
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Host");
- if(e)
- {
- memCgi << end_str << "HTTP_HOST=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Cookie");
- if(e)
- {
- memCgi << end_str << "HTTP_COOKIE=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Connection");
- if(e)
- {
- memCgi << end_str << "HTTP_CONNECTION=";
- memCgi << e->value->c_str();
- }
- }
-
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("User-Agent");
- if(e)
- {
- memCgi << end_str << "HTTP_USER_AGENT=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Accept");
- if(e)
- {
- memCgi << end_str << "HTTP_ACCEPT=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Content-Type");
- if(e)
- {
- memCgi << end_str << "CONTENT_TYPE=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Cache-Control");
- if(e)
- {
- memCgi << end_str << "HTTP_CACHE_CONTROL=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Referer");
- if(e)
- {
- memCgi << end_str << "HTTP_REFERER=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Accept-Encoding");
- if(e)
- {
- memCgi << end_str << "HTTP_ACCEPT_ENCODING=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("From");
- if(e)
- {
- memCgi << end_str << "HTTP_FROM=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Accept-Language");
- if(e)
- {
- memCgi << end_str << "HTTP_ACCEPT_LANGUAGE=";
- memCgi << e->value->c_str();
- }
- }
-
- {
- HttpRequestHeader::Entry* e = td->request.other.get("Accept-Charset");
- if(e)
- {
- memCgi << end_str << "HTTP_ACCEPT_CHARSET=";
- memCgi << e->value->c_str();
- }
- }
-
if(td->pathInfo.length())
{
memCgi << end_str << "PATH_INFO=";
@@ -964,6 +851,43 @@
memCgi << end_str << "REMOTE_IDENT=";
memCgi << td->connection->getLogin();
}
+
+ if(td->request.auth.length())
+ {
+ memCgi << end_str << "AUTH_TYPE=";
+ memCgi << td->request.auth.c_str();
+ }
+
+
+ {
+ HttpRequestHeader::Entry* e = td->request.other.get("Content-Type");
+ if(e)
+ {
+ memCgi << end_str << "CONTENT_TYPE=";
+ memCgi << e->value->c_str();
+ }
+ }
+
+
+ {
+
+ HashMap<string, HttpRequestHeader::Entry*>::Iterator it =
td->request.begin();
+ for(; it != td->request.end(); it++)
+ {
+ HttpRequestHeader::Entry* en = *it;
+ string name;
+
+ name.assign("HTTP_");
+ name.append(en->name->c_str());
+ transform(name.begin()+5, name.end(), name.begin()+5, ::toupper);
+ for(int i = name.length(); i > 5; i--)
+ if(name[i] == '-')
+ name[i] = '_';
+
+ memCgi << end_str << name.c_str() << "=" << en->value->c_str();
+ }
+ }
+
#ifdef WIN32
if(processEnv)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Myserver-commit] [2737] Method simplified,
Giuseppe Scrivano <=