|
From: andrew7 <bd...@us...> - 2007-06-11 01:10:53
|
Update of /cvsroot/smartwin/SmartWin/SmartNetwork In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5924 Modified Files: HttpRequest.cpp HttpRequest.h NetworkSystemHeaders.h TcpTextStream.cpp TcpTextStream.h Log Message: Unicode conversion Index: TcpTextStream.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/SmartNetwork/TcpTextStream.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TcpTextStream.cpp 5 May 2006 17:21:44 -0000 1.2 +++ TcpTextStream.cpp 11 Jun 2007 01:10:45 -0000 1.3 @@ -33,10 +33,12 @@ namespace SmartNetwork { -TcpTextStream::TcpTextStream( const std::string & serverIpAddress, const std::string & port, unsigned int timeout, SmartUtil::ConversionCodepage::Codepage codepage ) +TcpTextStream::TcpTextStream( const SmartUtil::tstring & serverIpAddress, const SmartUtil::tstring & port, unsigned int timeout, SmartUtil::ConversionCodepage::Codepage codepage ) : std::basic_iostream< TCHAR >( & itsTcpStreamBuffer ), itsTcpStreamBuffer( timeout, codepage ) { - itsTcpStreamBuffer.clientInit( serverIpAddress, port ); + std::string serverIpAddr_ascii = SmartUtil::AsciiGuaranteed::doConvert( serverIpAddress.c_str(), codepage ); + std::string port_ascii = SmartUtil::AsciiGuaranteed::doConvert( port.c_str(), codepage ); + itsTcpStreamBuffer.clientInit( serverIpAddr_ascii, port_ascii ); } } Index: HttpRequest.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/SmartNetwork/HttpRequest.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HttpRequest.h 5 May 2006 17:14:40 -0000 1.5 +++ HttpRequest.h 11 Jun 2007 01:10:45 -0000 1.6 @@ -51,7 +51,7 @@ std::vector< SmartUtil::tstring > itsHeaders; SmartUtil::tstring itsPostUrl; SmartUtil::tstring itsContentType; - std::string itsHost; + const SmartUtil::tstring itsHost; HttpRequest( const HttpRequest & rhs ); // Never implemented...!! @@ -66,10 +66,10 @@ * The timeout value defines how long time the request will wait after sending the request before it "gives up" getting a return value * and raises an exception. */ - HttpRequest( const std::string & host, const SmartUtil::tstring & postUrl, const SmartUtil::tstring & contentType, const std::string & port, unsigned int timeout ); + HttpRequest( const SmartUtil::tstring & host, const SmartUtil::tstring & postUrl, const SmartUtil::tstring & contentType, const SmartUtil::tstring & port, unsigned int timeout ); /// Parses the host and path automatically and adds up the parameters - HttpRequest( const std::string & connectionString, const SmartUtil::tstring & contentType, const std::string & port, unsigned int timeout ); + HttpRequest( const SmartUtil::tstring & connectionString, const SmartUtil::tstring & contentType, const SmartUtil::tstring & port, unsigned int timeout ); /// Adds up an HTTP header /** By default only the "POST", "Host:", "Content-Length:" and the "Content-Type:" headers are included. Index: TcpTextStream.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/SmartNetwork/TcpTextStream.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TcpTextStream.h 5 May 2006 17:14:40 -0000 1.3 +++ TcpTextStream.h 11 Jun 2007 01:10:45 -0000 1.4 @@ -58,7 +58,7 @@ * is the amount of seconds we wait after starting a "read action" before we give up and throws an exception. * Stream is synchronous meaning if you need asynchronous access you need to wrap it yourself! */ - TcpTextStream( const std::string & serverHostAddress, const std::string & port, unsigned int timeout, + TcpTextStream( const SmartUtil::tstring & serverHostAddress, const SmartUtil::tstring & port, unsigned int timeout, SmartUtil::ConversionCodepage::Codepage codepage = SmartUtil::ConversionCodepage::UTF8 ); }; } Index: HttpRequest.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/SmartNetwork/HttpRequest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HttpRequest.cpp 5 May 2006 17:21:44 -0000 1.5 +++ HttpRequest.cpp 11 Jun 2007 01:10:45 -0000 1.6 @@ -34,29 +34,29 @@ namespace SmartHTTP { -HttpRequest::HttpRequest( const std::string & host, const SmartUtil::tstring & postUrl, const SmartUtil::tstring & contentType, const std::string & port, unsigned int timeout ) +HttpRequest::HttpRequest( const SmartUtil::tstring & host, const SmartUtil::tstring & postUrl, const SmartUtil::tstring & contentType, const SmartUtil::tstring & port, unsigned int timeout ) : itsTcp( new SmartNetwork::TcpTextStream( host, port, timeout ) ), itsPostUrl( postUrl ), itsContentType( contentType ), itsHost( host ) {} -std::string getHost( const std::string & conn ) +const SmartUtil::tstring getHost( const SmartUtil::tstring & conn ) { size_t startOfHost = conn.find_first_of( ':' ) + 3; size_t endOfHost = conn.find_first_of( '/', startOfHost ); - std::string retVal = conn.substr( startOfHost, endOfHost - startOfHost ); + SmartUtil::tstring retVal = conn.substr( startOfHost, endOfHost - startOfHost ); return retVal; } -SmartUtil::tstring getPostPath( const std::string & conn ) +SmartUtil::tstring getPostPath( const SmartUtil::tstring & conn ) { size_t startOfHost = conn.find_first_of( '/', conn.find_first_of( ':' ) + 4 ); - std::string retVal = conn.substr( startOfHost ); - return SmartUtil::Ascii2CurrentBuild::doConvert( retVal, SmartUtil::ConversionCodepage::ANSI ); + SmartUtil::tstring retVal = conn.substr( startOfHost ); + return retVal; } -HttpRequest::HttpRequest( const std::string & connectionString, const SmartUtil::tstring & contentType, const std::string & port, unsigned int timeout ) +HttpRequest::HttpRequest( const SmartUtil::tstring & connectionString, const SmartUtil::tstring & contentType, const SmartUtil::tstring & port, unsigned int timeout ) : itsTcp( new SmartNetwork::TcpTextStream( getHost( connectionString ), port, timeout ) ), itsPostUrl( getPostPath( connectionString ) ), itsContentType( contentType ), @@ -80,7 +80,7 @@ headers.push_back( SmartUtil::tstring( _T( "POST " ) ) + itsPostUrl + _T( " HTTP/1.0" ) ); // TODO: Optimize!! Really SLOW!! - headers.push_back( SmartUtil::tstring( _T( "Host: " ) ) + SmartUtil::Ascii2CurrentBuild::doConvert( itsHost, SmartUtil::ConversionCodepage::ANSI ) ); + headers.push_back( SmartUtil::tstring( _T( "Host: " ) ) + itsHost ); headers.push_back( SmartUtil::tstring( _T( "Content-Type: " ) ) + itsContentType ); headers.push_back( _T( "Content-Length: " ) + boost::lexical_cast< SmartUtil::tstring >( static_cast< unsigned >( SmartUtil::AsciiGuaranteed::doConvert( requestContent, SmartUtil::ConversionCodepage::UTF8 ).size() ) ) ); Index: NetworkSystemHeaders.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/SmartNetwork/NetworkSystemHeaders.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- NetworkSystemHeaders.h 24 Dec 2006 17:12:52 -0000 1.5 +++ NetworkSystemHeaders.h 11 Jun 2007 01:10:45 -0000 1.6 @@ -49,6 +49,7 @@ #ifndef WINCE #ifndef __GNUC__ #pragma comment( lib, "wsock32.lib" ) + #pragma comment( lib, "Ws2_32.lib" ) #endif #else #ifndef __GNUC__ |