Author: nadiramra
Date: Sat Mar 26 04:40:11 2011
New Revision: 1085643

URL: http://svn.apache.org/viewvc?rev=1085643&view=rev
Log:
AXISCPP-829 - HTTP header field case sensitivity

Modified:
    axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp
    axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
    axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp
    axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp
    axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
    axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp

Modified: axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp
URL: 
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp?rev=1085643&r1=1085642&r2=1085643&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp Sat Mar 26 
04:40:11 2011
@@ -82,6 +82,11 @@
 
 #define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S     "<>&\"\'"
 
+// Case-insensitive string compares
+#include <strings.h>    // for strcasecmp()
+
+#define PLATFORM_STRCASECMP strcasecmp
+
 // =============================================================
 // Miscellaneous
 // =============================================================

Modified: axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
URL: 
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp?rev=1085643&r1=1085642&r2=1085643&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp Sat Mar 26 
04:40:11 2011
@@ -81,6 +81,11 @@
 
 #define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S     "<>&\"\'"
 
+// Case-insensitive string compares
+#include <strings.h>    // for strcasecmp()
+
+#define PLATFORM_STRCASECMP strcasecmp
+
 // =============================================================
 // Miscellaneous
 // =============================================================

Modified: axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp
URL: 
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp?rev=1085643&r1=1085642&r2=1085643&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp Sat Mar 26 
04:40:11 2011
@@ -22,6 +22,7 @@
 #include <stdio.h>      
 #include <stdlib.h>      
 #include <string.h>      
+#include <strings.h>    // for strcasecmp()
 #include <errno.h>
 #include <stdarg.h>
 #include <time.h>       // strftime(), localtime()      
@@ -79,6 +80,9 @@ extern char*      asctostr( char* );
 #define PLATFORM_STRTOASC( x ) strtoasc( (char*)(x) )
 #define PLATFORM_ASCTOSTR( x ) asctostr( (char*)(x) )
 
+// Case-insensitive string compares
+#define PLATFORM_STRCASECMP strcasecmp
+
 // reference to ebcdic to ascii conversion table 
 extern const char EBCDICtoASCII[256];
 

Modified: axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp
URL: 
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp?rev=1085643&r1=1085642&r2=1085643&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp Sat Mar 26 
04:40:11 2011
@@ -82,6 +82,11 @@
 
 #define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S     "<>&\"\'"
 
+// Case-insensitive string compares
+#include <strings.h>    // for strcasecmp()
+
+#define PLATFORM_STRCASECMP strcasecmp
+
 // =============================================================
 // Miscellaneous
 // =============================================================

Modified: axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
URL: 
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp?rev=1085643&r1=1085642&r2=1085643&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp 
(original)
+++ axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp Sat 
Mar 26 04:40:11 2011
@@ -60,6 +60,7 @@
 #include <windows.h>
 #include <string>
 #include <sys/timeb.h>
+#include <string.h>
 
 #define DIR_SEPARATOR   '\\'
 #define DIR_SEPARATOR_S "\\"
@@ -114,6 +115,9 @@
 
 #define PLATFORM_XML_ENTITY_REFERENCE_CHARS_S     "<>&\"\'"
 
+// Case-insensitive string compares
+#define PLATFORM_STRCASECMP _stricmp
+
 // =============================================================
 // Miscellaneous
 // =============================================================

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp
URL: 
http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp?rev=1085643&r1=1085642&r2=1085643&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp Sat Mar 26 
04:40:11 2011
@@ -398,7 +398,7 @@ generateHTTPHeaders()
     // The Content-Type must be set, but it may already be set.
     bool foundCT = false;
     for (unsigned int j = 0; j < m_vHTTPHeaders.size (); j++)
-        if (0==strcmp(AXIS_CONTENT_TYPE,m_vHTTPHeaders[j].first.c_str()))
+        if 
(0==PLATFORM_STRCASECMP(AXIS_CONTENT_TYPE,m_vHTTPHeaders[j].first.c_str()))
             foundCT = true;
 
     if (!foundCT)
@@ -431,15 +431,15 @@ generateHTTPHeaders()
     // Set other HTTP headers but not cookies as they are put in afterwards.
     for (unsigned int i = 0; i < m_vHTTPHeaders.size (); i++)
     {
-        if( strcmp(m_vHTTPHeaders[i].first.c_str(), "Cookie")!=0)
+        if( PLATFORM_STRCASECMP(m_vHTTPHeaders[i].first.c_str(), "Cookie")!=0)
         {
             m_strHeaderBytesToSend += m_vHTTPHeaders[i].first;
             m_strHeaderBytesToSend += ": ";
             m_strHeaderBytesToSend += m_vHTTPHeaders[i].second;
             m_strHeaderBytesToSend += "\r\n";
             
-            if (0==strcmp("Connection",m_vHTTPHeaders[i].first.c_str())
-                    && 0==strcmp("close", m_vHTTPHeaders[i].second.c_str()))
+            if 
(0==PLATFORM_STRCASECMP("Connection",m_vHTTPHeaders[i].first.c_str())
+                    && 0==PLATFORM_STRCASECMP("close", 
m_vHTTPHeaders[i].second.c_str()))
                 m_bReopenConnection = true;
         }
     }
@@ -472,7 +472,7 @@ generateHTTPHeaders()
         bool b_keyFound=false;
         for (unsigned int i = 0; i < m_vHTTPHeaders.size(); i++)
         {
-            if (m_vHTTPHeaders[i].first == (string)"Cookie")
+            if (PLATFORM_STRCASECMP(m_vHTTPHeaders[i].first.c_str(), "Cookie") 
== 0)
             {
                 m_vHTTPHeaders[i].second = (string) cookieHeader;
                 b_keyFound = true;
@@ -937,7 +937,7 @@ setTransportProperty( AXIS_TRANSPORT_INF
 
         case TRANSPORT_PROPERTIES:
         {
-            if (value && strcmp(value, "Connection: close") == 0)
+            if (value && (PLATFORM_STRCASECMP(value, "Connection: close") == 
0))
                 setTransportProperty("Connection", "close");
             else if( m_pActiveChannel != NULL)
                 m_pActiveChannel->setTransportProperty( type, value);
@@ -971,7 +971,7 @@ setTransportProperty( AXIS_TRANSPORT_INF
 
         case ENABLE_AUTOMATIC_REDIRECT:
         {
-            if (value && strcmp(value, "true") == 0)
+            if (value && (PLATFORM_STRCASECMP(value, "true") == 0))
                 m_bPerformAutoRedirect = true;
             else
                 m_bPerformAutoRedirect = false;
@@ -1034,17 +1034,15 @@ setTransportProperty( const char *pcKey,
         // Cookies are handled elsewhere.  For other properties, we first 
check to
         // see if there is a matching (i.e. duplicate property) already set.  
If one
         // exists, we replace the value.
-        if(strcmp(pcKey, "Cookie")==0)
+        if(PLATFORM_STRCASECMP(pcKey, "Cookie")==0)
         {
             iSuccess = addCookie(pcValue);
             b_KeyFound = true;
         }
         else
         {
-            std::string strKeyToFind = std::string( pcKey);
-    
             for (unsigned int i = 0; i < m_vHTTPHeaders.size(); i++)
-                if (m_vHTTPHeaders[i].first == strKeyToFind)
+                if (PLATFORM_STRCASECMP(m_vHTTPHeaders[i].first.c_str(), 
pcKey) == 0)
                 {
                     m_vHTTPHeaders[i].second = (string) pcValue;
                     b_KeyFound = true;
@@ -1420,7 +1418,7 @@ processHTTPHeader()
 
         // Content length set? Chunked overrides Content-length. It should be 
noted
         // that on successful one-way requests Content-Length would be set to 
zero.
-        if (key == "Content-Length")
+        if (PLATFORM_STRCASECMP(key.c_str(), "Content-Length") == 0)
             if (m_GetBytesState != eSOAPMessageIsChunked)
             {
                 m_iContentLength = atoi(value.c_str());
@@ -1428,11 +1426,12 @@ processHTTPHeader()
             }
 
         // Redirect?
-        if (key == "Location")
+        if (PLATFORM_STRCASECMP(key.c_str(), "Location") == 0)
             m_strResponseLocationURI = value;
 
         // Is chunked? 
-        if (key == "Transfer-Encoding" && value == "chunked")
+        if ((PLATFORM_STRCASECMP(key.c_str(), "Transfer-Encoding") == 0)
+                && (PLATFORM_STRCASECMP(value.c_str(), "chunked") == 0))
             m_GetBytesState = eSOAPMessageIsChunked;
 
         // Now handle whether we are going to close connection after 
processing 
@@ -1442,27 +1441,30 @@ processHTTPHeader()
             m_bReopenConnection = true;
 
         // We need to close the connection and open a new one if we have 
'Connection: close'
-        if( key == "Connection" && (value == "close" || value == "Close"))
+        if ((PLATFORM_STRCASECMP(key.c_str(), "Connection") == 0)
+                && (PLATFORM_STRCASECMP(value.c_str(), "close") == 0))
         {
             m_bReopenConnection = true;
             m_pActiveChannel->closeQuietly( true);
         }
 
         // We need to close the connection and open a new one if we have 
'Proxy-Connection: close'
-        if (key == "Proxy-Connection" && (value == "close" || value == 
"Close"))
+        if ((PLATFORM_STRCASECMP(key.c_str(), "Proxy-Connection") == 0)
+                && (PLATFORM_STRCASECMP(value.c_str(), "close") == 0))
             m_bReopenConnection = true;
 
         // For both HTTP/1.0 and HTTP/1.1, We need to keep the connection if 
we have 'Connection: Keep-Alive'
-        if( key == "Connection" && value == "Keep-Alive")
+        if ((PLATFORM_STRCASECMP(key.c_str(), "Connection") == 0)
+                && (PLATFORM_STRCASECMP(value.c_str(), "Keep-Alive") == 0))
             m_bReopenConnection = false;
 
         // Look for cookies
-        if( m_bMaintainSession )
-            if( key == "Set-Cookie")
+        if ( m_bMaintainSession )
+            if (PLATFORM_STRCASECMP(key.c_str(), "Set-Cookie") == 0)
                 addCookie(value);
 
         /* If Content-Type: Multipart/Related; boundary=<MIME_boundary>; 
type=text/xml; start="<content id>" */
-        if( key == "Content-Type")
+        if (PLATFORM_STRCASECMP(key.c_str(), "Content-Type") == 0)
         {
             m_strResponseContentType = value;
 
@@ -1472,7 +1474,7 @@ processHTTPHeader()
             if( ulMimePos != std::string::npos)
                 strTypePart = m_strResponseContentType.substr( 1, ulMimePos - 
1);
 
-            if( "Multipart/Related" == strTypePart)
+            if ( "Multipart/Related" == strTypePart)
             {
                 m_bMimeTrue = true;
                 m_strResponseContentType = m_strResponseContentType.substr( 
ulMimePos + 1, m_strResponseContentType.length());
@@ -1665,7 +1667,9 @@ getTransportProperty( const char * pcKey
     
     const char *returnValue = NULL;
 
-    std::string strKeyToFind = std::string( pcKey);
+    if (pcKey == NULL)
+        return NULL;
+
     std::vector < std::pair < std::string, std::string > > *hdrs=NULL;
     
     if (response)
@@ -1674,7 +1678,7 @@ getTransportProperty( const char * pcKey
         hdrs = &m_vHTTPHeaders;
 
     for( unsigned int i = 0; i < hdrs->size(); i++)
-        if( (*hdrs)[i].first == strKeyToFind)
+        if (PLATFORM_STRCASECMP((*hdrs)[i].first.c_str(), pcKey) == 0)
         {
             returnValue = (*hdrs)[i].second.c_str();
             break;
@@ -1791,19 +1795,22 @@ deleteCurrentTransportProperty(bool resp
 void HTTPTransport::
 deleteTransportProperty (char *pcKey, unsigned int uiOccurance)
 {
+    if (pcKey == NULL)
+        return;
+
     vector < std::pair < std::string,
     std::string > >::iterator currentHeader = m_vHTTPHeaders.begin();
     unsigned int uiCount = 1;
     bool found=false;
     while( currentHeader != m_vHTTPHeaders.end() && uiCount <= uiOccurance)
     {
-        if( strcmp( pcKey, (*currentHeader).first.c_str()) == 0)
+        if (PLATFORM_STRCASECMP(pcKey, (*currentHeader).first.c_str()) == 0)
         {
             if( uiCount == uiOccurance)
             {
                 m_vHTTPHeaders.erase( currentHeader);
                 // if this is the special case of cookies then delete them all
-                if(strcmp(pcKey, "Cookie")==0)
+                if (PLATFORM_STRCASECMP(pcKey, "Cookie")==0)
                     removeAllCookies();
                 found=true;
                 break;


Reply via email to