You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ro...@apache.org on 2003/10/19 19:03:56 UTC
cvs commit: ws-axis/c/src/server/simple_axis_server HTTP_KeyWords.h SimpleAxisServer.cpp ServerHelper.h ServerHelper.cpp
roshan 2003/10/19 10:03:56
Modified: c/src/server/simple_axis_server SimpleAxisServer.cpp
ServerHelper.h ServerHelper.cpp
Added: c/src/server/simple_axis_server HTTP_KeyWords.h
Log:
added code to support HTTP Header processing
Revision Changes Path
1.11 +12 -3 ws-axis/c/src/server/simple_axis_server/SimpleAxisServer.cpp
Index: SimpleAxisServer.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/simple_axis_server/SimpleAxisServer.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SimpleAxisServer.cpp 16 Oct 2003 12:05:35 -0000 1.10
+++ SimpleAxisServer.cpp 19 Oct 2003 17:03:56 -0000 1.11
@@ -91,6 +91,7 @@
char echoBuffer[RCVBUFSIZE]; /* Buffer for echo string */
const char *pcHttpBody;
int iClntSocket;
+map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> map_HTTP_Headers;
int send_response_bytes(const char * res, const void* opstream)
{
@@ -142,8 +143,16 @@
//str->so.http.ip_headers->headername = SOAPACTIONHEADER;
//str->so.http.ip_headers->headervalue = "\"Calculator\"";
str->so.http.ip_headercount = 0;
- //str->so.http.uri_path = "http://someurl/axis/Calculator";
- str->so.http.uri_path = "http://someurl/axis/Deployment";
+
+ char pchURIValue[100] = {0};
+ strcat(pchURIValue, "http://someurl");
+
+ if (map_HTTP_Headers.find(HMK_URI) != map_HTTP_Headers.end()) {
+ const char* pChTemp = map_HTTP_Headers[HMK_URI]->objuHttpMapContent->msValue;
+ strcat(pchURIValue, pChTemp);
+ }
+
+ str->so.http.uri_path = pchURIValue;
//set transport
str->transport.pSendFunct = send_response_bytes;
@@ -246,7 +255,7 @@
string sHTTPHeaders = "";
string sHTTPBody = "";
- getSeperatedHTTPParts(sClientReqStream, sHTTPHeaders, sHTTPBody);
+ getSeperatedHTTPParts(sClientReqStream, sHTTPHeaders, sHTTPBody, &map_HTTP_Headers);
//DEBUG info
//printf("----------START extracted HTTP Headers------------\n");
1.5 +22 -1 ws-axis/c/src/server/simple_axis_server/ServerHelper.h
Index: ServerHelper.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/simple_axis_server/ServerHelper.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerHelper.h 15 Oct 2003 06:11:29 -0000 1.4
+++ ServerHelper.h 19 Oct 2003 17:03:56 -0000 1.5
@@ -65,9 +65,30 @@
#define AFX_SERVERHELPER_H__INCLUDED_
#include <string>
+#include <map>
+
+#include "HTTP_KeyWords.h"
using namespace std;
-int getSeperatedHTTPParts(string sClientReqStream, string& sHTTPHeaders, string& sHTTPBody);
+enum CONTENT_TYPE {
+ HTTP_KEYWORD_TYPE,
+ STRING_TYPE
+};
+
+union uHttpMapContent /*this is used to store both the HTTP_KEYWORDS enumerated contents and strings*/
+{
+ HTTP_KEYWORDS eHTTP_KEYWORD; //for HTTP_KEYWORDS enumerated contents
+ const char* msValue; //for string content
+};
+
+struct HTTP_MAP_TYPE {
+ CONTENT_TYPE eCONTENT_TYPE;
+ uHttpMapContent* objuHttpMapContent;
+};
+
+int getSeperatedHTTPParts(string sClientReqStream, string& sHTTPHeaders, string& sHTTPBody, map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> *map_HTTP_Headers);
+int initializeHeaderMap(const string &HeaderLine, map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> *map_HTTP_Headers);
+int getHttpHeader(HTTP_MAP_KEYWORDS eKeyWord, map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> *map_HTTP_Headers, HTTP_MAP_TYPE *objMapContent);
#endif // !defined(AFX_SERVERHELPER_H__INCLUDED_)
1.4 +123 -3 ws-axis/c/src/server/simple_axis_server/ServerHelper.cpp
Index: ServerHelper.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/simple_axis_server/ServerHelper.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServerHelper.cpp 1 Oct 2003 08:04:30 -0000 1.3
+++ ServerHelper.cpp 19 Oct 2003 17:03:56 -0000 1.4
@@ -61,11 +61,19 @@
*
*/
+#ifdef WIN32
+#pragma warning (disable : 4786)
+#endif
+
#include <iostream>
#include <stdio.h>
+#include <map>
#include "ServerHelper.h"
+#include "../../common/AxisUtils.h"
+
+using namespace std;
-int getSeperatedHTTPParts(string sClientReqStream, string& sHTTPHeaders, string& sHTTPBody) {
+int getSeperatedHTTPParts(string sClientReqStream, string& sHTTPHeaders, string& sHTTPBody, map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> *map_HTTP_Headers) {
int iFindStartLocation=0;
string sTmpHttpHeader= "";
@@ -93,13 +101,19 @@
if(sTmpHttpHeader.size() == 1) {
bContinue= false;
- } else {
+ } else {
+
+ /*------------do we need this now ? ------------------*/
if(bFirstTime) {
sHTTPHeaders += sTmpHttpHeader;
bFirstTime = false;
} else {
sHTTPHeaders += "|" + sTmpHttpHeader;
- }
+ }
+ /*-------------end-----------------*/
+
+ initializeHeaderMap(sTmpHttpHeader, map_HTTP_Headers);
+ //initializeHeaderMap(map_HTTP_Headers);
}
iFindStartLocation = iLocation+1;
@@ -114,3 +128,109 @@
// return a status code : 1- SUCCESS
return 1;
}
+
+int initializeHeaderMap(const string &sHeaderLine, map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> *map_HTTP_Headers) {
+
+ bool bIsHttpHeader = true;
+ int iHeaderLineLength = sHeaderLine.size();
+
+ if (!AxisUtils::isCharacterAvailable(sHeaderLine, ':')) {
+ bIsHttpHeader = false;
+ }
+
+ if (!bIsHttpHeader) {
+ /*
+ Here we expect a Header line with the pattern "POST axis/Calculatoer HTTP/1.1".
+ The logic is based on this pattern
+ */
+
+ int iLocation = 0;
+ int iFindStartLocation = 0;
+ int iGap= 0;
+
+ for (int iRoundNo= 0; iRoundNo<3; iRoundNo++) {
+ /*
+ *Seperate the Method, URI, and HTTP Version from the string HeaderLine and add them to the map
+ */
+
+ string *sTmpValue = new string("");
+
+ if (iRoundNo == 2) {
+ iGap = (iHeaderLineLength) - iFindStartLocation;
+ } else {
+ iLocation = sHeaderLine.find(' ', iFindStartLocation);
+
+ iGap = iLocation-iFindStartLocation;
+ }
+ if (iGap == 0) {
+ *sTmpValue = sHeaderLine.substr(iFindStartLocation, 1);
+ } else {
+ *sTmpValue = sHeaderLine.substr(iFindStartLocation, iGap);
+ }
+
+ iFindStartLocation = iLocation+1;
+
+ uHttpMapContent* objuHttpMapContent = (uHttpMapContent*)malloc(sizeof(uHttpMapContent));
+ HTTP_MAP_TYPE* objHTTP_MAP_Value = (HTTP_MAP_TYPE*)malloc(sizeof(HTTP_MAP_TYPE));
+
+ switch (iRoundNo) {
+ /*case 0:
+ /*sTmpValue = AxisUtils::toLowerCase(sTmpValue);
+ if (sTmpValue == "post") {*/
+ /* if (sTmpValue == "POST") {
+ objuHttpMapContent.eHTTP_KEYWORD = HK_POST;
+
+ /*if (sTmpValue == "get") {*/
+ /* } else if (sTmpValue == "GET") {
+ objuHttpMapContent.eHTTP_KEYWORD = HK_GET;
+ }
+ objHTTP_MAP_Value.eCONTENT_TYPE= HTTP_KEYWORD_TYPE;
+ objHTTP_MAP_Value.objuHttpMapContent = objuHttpMapContent;
+ (*map_HTTP_Headers)[HMK_METHOD] = objHTTP_MAP_Value;
+ break;*/
+ case 1:
+ objuHttpMapContent->msValue = sTmpValue->c_str();
+ objHTTP_MAP_Value->eCONTENT_TYPE= STRING_TYPE;
+ objHTTP_MAP_Value->objuHttpMapContent = objuHttpMapContent;
+ (*map_HTTP_Headers)[HMK_URI] = objHTTP_MAP_Value;
+ printf("in case1 = %s\n", (*map_HTTP_Headers)[HMK_URI]->objuHttpMapContent->msValue);
+ break;
+ /*case 2:
+ /*sTmpValue = AxisUtils::toLowerCase(sTmpValue);
+ if (sTmpValue == "http/1.1") {*/
+ /* if (sTmpValue == "HTTP/1.1") {
+ objuHttpMapContent.eHTTP_KEYWORD = HK_HTTP_1_1;
+
+ } else {
+ objuHttpMapContent.eHTTP_KEYWORD = HK_HTTP_UNKNOWN_VERSION;
+ }
+ objHTTP_MAP_Value.eCONTENT_TYPE= HTTP_KEYWORD_TYPE;
+ objHTTP_MAP_Value.objuHttpMapContent = objuHttpMapContent;
+ (*map_HTTP_Headers)[HMK_VERSION] = objHTTP_MAP_Value;
+ break;*/
+ }
+ }
+ } else {
+ /*
+ * Seperate the Header name and value from ":" and put them to the map
+ */
+ //map_HTTP_Headers[HK_URI] = "extracted Value";
+ }
+
+ return 1;
+}
+
+int getHttpHeader(HTTP_MAP_KEYWORDS eKeyWord, map<HTTP_MAP_KEYWORDS, HTTP_MAP_TYPE*> *map_HTTP_Headers, HTTP_MAP_TYPE *objMapContent) {
+
+ int iStatus = FAIL;
+
+ if (map_HTTP_Headers->find(eKeyWord) != map_HTTP_Headers->end()) {
+ printf("debgu 1 = %s\n", (*map_HTTP_Headers)[eKeyWord]->objuHttpMapContent->msValue);
+ objMapContent = (HTTP_MAP_TYPE*) malloc(sizeof((*map_HTTP_Headers)[eKeyWord]));
+ objMapContent = (*map_HTTP_Headers)[eKeyWord];
+
+ iStatus = SUCCESS;
+ }
+
+ return iStatus;
+}
\ No newline at end of file
1.1 ws-axis/c/src/server/simple_axis_server/HTTP_KeyWords.h
Index: HTTP_KeyWords.h
===================================================================
/* -*- C++ -*- */
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "SOAP" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*
*
*
* @author Roshan Weerasuriya (roshan@jkcs.slt.lk, roshan@opensource.lk)
*
*/
#if !defined(AFX_HTTPKEYWORDS_H__INCLUDED_)
#define AFX_HTTPKEYWORDS_H__INCLUDED_
#include <string>
using namespace std;
enum HTTP_MAP_KEYWORDS {
HMK_URI, /*For HTTP URI*/
HMK_METHOD, /*For HTTP method (eg: GET, POST etc)*/
HMK_VERSION, /*For HTTP Version*/
HMK_HOST, /*For Host name*/
HMK_CONTENT_TYPE, /*For Content Type*/
HMK_CONTENT_LENGTH, /*For Content Length*/
HMK_LAST /*For Representing the last item of the enumeration*/
};
enum HTTP_KEYWORDS {
HK_POST, /*For HTTP POST*/
HK_GET, /*For HTTP GET*/
HK_HTTP_1_1, /*For HTTP 1.1*/
HK_HTTP_UNKNOWN_VERSION, /*For unknown versions of HTTP*/
HK_LAST /*For Representing the last item of the enumeration*/
};
#endif // !defined(AFX_HTTPKEYWORDS_H__INCLUDED_)