Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 47476 invoked from network); 29 Sep 2004 08:26:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 Sep 2004 08:26:44 -0000 Received: (qmail 61151 invoked by uid 500); 29 Sep 2004 08:26:40 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 61064 invoked by uid 500); 29 Sep 2004 08:26:39 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 61041 invoked by uid 99); 29 Sep 2004 08:26:38 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 29 Sep 2004 01:26:38 -0700 Received: (qmail 47355 invoked by uid 1852); 29 Sep 2004 08:26:37 -0000 Date: 29 Sep 2004 08:26:37 -0000 Message-ID: <20040929082637.47354.qmail@minotaur.apache.org> From: samisa@apache.org To: ws-axis-cvs@apache.org Subject: cvs commit: ws-axis/c/src/transport/axis2 Axis2Transport.h Axis2Transport.cpp X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N samisa 2004/09/29 01:26:37 Modified: c/src/transport/axis2 Axis2Transport.h Axis2Transport.cpp Log: Added HTTP header processing logic for incomming messages. Revision Changes Path 1.2 +101 -70 ws-axis/c/src/transport/axis2/Axis2Transport.h Index: Axis2Transport.h =================================================================== RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Axis2Transport.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Axis2Transport.h 21 Sep 2004 03:52:24 -0000 1.1 +++ Axis2Transport.h 29 Sep 2004 08:26:37 -0000 1.2 @@ -27,153 +27,171 @@ #include #include -AXIS_CPP_NAMESPACE_USE -using namespace std; +AXIS_CPP_NAMESPACE_USE using namespace std; int axtoi (char *hexStg); -class Axis2Transport : public SOAPTransport +class Axis2Transport:public SOAPTransport { -public: - Axis2Transport(); - virtual ~Axis2Transport(); - + public: + Axis2Transport (); + virtual ~ Axis2Transport (); + /** * Sets the endpoint URI. * Keeps track of the changes made to the URI. (Because if the URI changes, * we cannot reuse the opned socket) * @param pcEndPointURI End point URI of the service to connect to. * e.g. http://localhost:8080/axis/services/echo - */ - void setEndpointUri(const char* pcEndpointUri); - int openConnection(); - void closeConnection(); - AXIS_TRANSPORT_STATUS sendBytes(const char* pcSendBuffer, const void* pBufferId); - void registerReleaseBufferCallback(AXIS_ENGINE_CALLBACK_RELEASE_SEND_BUFFER pFunct) - { m_pReleaseBufferCallback = pFunct; }; - AXIS_TRANSPORT_STATUS getBytes(char* pcBuffer, int* piSize); - void setTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE eType, const char* pcValue); - const char* getTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE eType); - void setTransportProperty(const char* pcKey, const char* pcValue); - const char* getTransportProperty(const char* pcKey){return "value";}; - void setAttachment(const char* pcAttachmentId, const char* pcAttachment){}; - const char* getAttachment(const char* pcAttachmentId){return "value";}; - - - void setSessionId(const char* pcSessionId){}; - const char* getSessionId(){return "some session id";}; - const char* getServiceName(); - AXIS_PROTOCOL_TYPE getProtocol(); - int getSubProtocol(); - AXIS_TRANSPORT_STATUS flushOutput(); - + */ + void setEndpointUri (const char *pcEndpointUri); + int openConnection (); + void closeConnection (); + AXIS_TRANSPORT_STATUS sendBytes (const char *pcSendBuffer, + const void *pBufferId); + void registerReleaseBufferCallback + (AXIS_ENGINE_CALLBACK_RELEASE_SEND_BUFFER pFunct) + { + m_pReleaseBufferCallback = pFunct; + }; + AXIS_TRANSPORT_STATUS getBytes (char *pcBuffer, int *piSize); + void setTransportProperty (AXIS_TRANSPORT_INFORMATION_TYPE eType, + const char *pcValue); + const char *getTransportProperty (AXIS_TRANSPORT_INFORMATION_TYPE eType); + void setTransportProperty (const char *pcKey, const char *pcValue); + const char *getTransportProperty (const char *pcKey) + { + return "value"; + }; + void setAttachment (const char *pcAttachmentId, const char *pcAttachment) + { + }; + const char *getAttachment (const char *pcAttachmentId) + { + return "value"; + }; + + + void setSessionId (const char *pcSessionId) + { + }; + const char *getSessionId () + { + return "some session id"; + }; + const char *getServiceName (); + AXIS_PROTOCOL_TYPE getProtocol (); + int getSubProtocol (); + AXIS_TRANSPORT_STATUS flushOutput (); + /** * Set proxy server and port for transport. * * @param pcProxyHost Host name of proxy server * @param uiProxyPort Port of proxy server */ - void setProxy(const char* pcProxyHost, unsigned int uiProxyPort); + void setProxy (const char *pcProxyHost, unsigned int uiProxyPort); /** * Set transport timeout. * * @param lSeconds Timeout in seconds */ - void setTimeout(const long lSeconds); - + void setTimeout (const long lSeconds); + /** * @return HTTP protocol in use - HTTP/1.1 or HTTP/1.0 - */ - const char* getHTTPProtocol(); - + */ + const char *getHTTPProtocol (); + /** * Sets the HTTP protocol to be 1.1 or 1.0 * @param iVersion Version to be used * If 0 HTTP/1.0 would be used, if 1 HTTP/1.1 would be used. * Default is HTTP1.1 */ - void setHTTPProtocol( int iVersion ); - + void setHTTPProtocol (int iVersion); + /** * @return HTTP Method in use - POST, GET etc. - */ - const char* getHTTPMethod(); - + */ + const char *getHTTPMethod (); + /** * Set HTTP Method to use * @param cpMethod - Possible values POST, GET, etc. * Only POST is handled correctly at the moment - */ - void setHTTPMethod(const char* cpMethod); - - const char* getHTTPHeaders(); + */ + void setHTTPMethod (const char *cpMethod); - + const char *getHTTPHeaders (); + + + + private: + + void processResponseHTTPHeaders(); -private: /** * Keeps track of URI changes. * Set true by setEndpointUri. * Set false when a socket connection is established with the enpoint. */ bool m_bURIChanged; - + /** * Channel used for comminication */ Channel m_Channel; - + /** * Message string to be sent. */ std::string m_strBytesToSend; - + /** * Vector to hold HTTP header key/value pairs - */ - std::vector< std::pair > m_vHTTPHeaders; - + */ + std::vector < std::pair < std::string, std::string > >m_vHTTPHeaders; /** * HTTP protocol (1.1 or 1.0). Default is HTTP/1.1 - */ + */ std::string m_strHTTPProtocol; - /** * HTTP method (POST, GET etc.) - Only support POST at the moment */ std::string m_strHTTPMethod; - + /** * Bytes left in the payload buffer to be read - */ + */ int m_iBytesLeft; - + /** * Payload lenght - */ + */ int m_iContentLength; - + /** * Is the message chunked - */ + */ int m_bChunked; - + /** * String holding what we received over the channel */ std::string m_strReceived; - + /** * Have we read past HTTP headers? */ bool m_bReadPastHTTPHeaders; - + /** * Payload buffer - */ - const char* m_pcReceived; - + */ + const char *m_pcReceived; + /** * Proxy server name. */ @@ -186,9 +204,22 @@ * Use Proxy or not? */ bool m_bUseProxy; - + /** + * HTTP headers in response + */ + std::string m_strResponseHTTPHeaders; + /** + * HTTP protocol (1.1 or 1.0). Default is HTTP/1.1 + */ + std::string m_strResponseHTTPProtocol; + /** + * HTTP status code + */ + std::string m_strResponseHTTPStatusCode; + /** + * Vector to hold response HTTP header key/value pairs + */ + std::vector < std::pair < std::string, std::string > >m_vResponseHTTPHeaders; }; #endif - - 1.2 +46 -0 ws-axis/c/src/transport/axis2/Axis2Transport.cpp Index: Axis2Transport.cpp =================================================================== RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Axis2Transport.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Axis2Transport.cpp 21 Sep 2004 03:52:24 -0000 1.1 +++ Axis2Transport.cpp 29 Sep 2004 08:26:37 -0000 1.2 @@ -201,6 +201,10 @@ m_bChunked = false; } + m_strResponseHTTPHeaders = m_strReceived.substr(0 ,m_strReceived.find ("\r\n\r\n") + 2 ); + + processResponseHTTPHeaders(); + // Skip headers and get payload m_strReceived = m_strReceived.substr(m_strReceived.find ("\r\n\r\n") + 4 ); } @@ -525,3 +529,45 @@ } return (intValue); } + +void Axis2Transport::processResponseHTTPHeaders() +{ + unsigned int iPosition = std::string::npos; + unsigned int iStartPosition = iPosition; + if ( (iPosition = m_strResponseHTTPHeaders.find("HTTP") ) != std::string::npos) + { + m_strResponseHTTPProtocol = m_strResponseHTTPHeaders.substr( iPosition, strlen ("HTTP/1.x") ); + iPosition += strlen ("HTTP/1.x"); + while( m_strResponseHTTPHeaders.substr()[iPosition] == ' ' ) + iPosition++; + iStartPosition = iPosition; + while( m_strResponseHTTPHeaders.substr()[iPosition] != ' ' ) + iPosition++; + + m_strResponseHTTPStatusCode = m_strResponseHTTPHeaders.substr( iStartPosition, iPosition - iStartPosition ); + // reached the end of the first line + iStartPosition = m_strResponseHTTPHeaders.find("\n"); + iStartPosition++; + + // read header fields and add to vector + do + { + m_strResponseHTTPHeaders = m_strResponseHTTPHeaders.substr( iStartPosition ); + iPosition = m_strResponseHTTPHeaders.find("\n"); + if ( iPosition == std::string::npos ) + break; + std::string strHeaderLine = m_strResponseHTTPHeaders.substr(0, iPosition); + unsigned int iSeperator = strHeaderLine.find(":"); + if (iSeperator == std::string::npos ) + break; + iStartPosition = iPosition + 1; + m_vResponseHTTPHeaders.push_back ( std::make_pair (strHeaderLine.substr(0, iSeperator), strHeaderLine.substr(iSeperator + 1, strHeaderLine.length() - iSeperator - 1 - 1 ) ) ); + } while (iPosition != std::string::npos); + + } + else + { + throw AxisTransportException(SERVER_TRANSPORT_UNKNOWN_HTTP_RESPONSE, "Protocol is not HTTP."); + } +} +