Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsnet_sockethttp.cpp File Reference
#include "vsnet_socket.h"
#include "vsnet_sockethttp.h"
#include "vsnet_oss.h"
#include "vsnet_err.h"
#include "lin_time.h"
#include "packet.h"
#include "netui.h"

Go to the source code of this file.

Functions

bool ishex (char x)
 
static void hostFromURI (const std::string &uri, std::string &host, std::string &fullhost, std::string &path, unsigned short &port)
 
static AddressIP remoteIPFromURI (const std::string &uri)
 
std::ostream & operator<< (std::ostream &ostr, const VsnetHTTPSocket &s)
 

Variables

int NONBLOCKING_CONNECT
 
int errchance = 9
 

Function Documentation

static void hostFromURI ( const std::string &  uri,
std::string &  host,
std::string &  fullhost,
std::string &  path,
unsigned short &  port 
)
static

Definition at line 57 of file vsnet_sockethttp.cpp.

Referenced by VsnetHTTPSocket::lower_selected(), remoteIPFromURI(), and VsnetHTTPSocket::VsnetHTTPSocket().

62 {
63  std::string protocol = uri.substr( 0, 7 );
64  std::string::size_type pos = 0;
65  if (protocol == "http://")
66  pos = 7;
67  std::string::size_type endhost = uri.find( ':', pos );
68  std::string::size_type endhostport = uri.find( '/', pos );
69  if (endhost == std::string::npos || endhost >= endhostport)
70  endhost = endhostport;
71  host = uri.substr( pos, endhost-pos );
72  fullhost = uri.substr( pos, endhostport-pos );
73  port = atoi( uri.substr( endhost+1, endhostport-endhost-1 ).c_str() );
74  if (!port)
75  port = 80;
76  path = uri.substr( endhostport );
77  if ( path.empty() )
78  path = "/";
79 }
bool ishex ( char  x)

Definition at line 43 of file vsnet_sockethttp.cpp.

Referenced by VsnetHTTPSocket::lower_selected().

44 {
45  if (x >= '0' && x <= '9') return true;
46  if (x >= 'a' && x <= 'f') return true;
47  if (x >= 'A' && x <= 'F') return true;
48  if (x == 'x' || x == 'X') return true;
49  return false;
50 }
std::ostream& operator<< ( std::ostream &  ostr,
const VsnetHTTPSocket s 
)

Definition at line 166 of file vsnet_sockethttp.cpp.

References VsnetHTTPSocket::dump().

167 {
168  s.dump( ostr );
169  return ostr;
170 }
static AddressIP remoteIPFromURI ( const std::string &  uri)
static

Definition at line 81 of file vsnet_sockethttp.cpp.

References hostFromURI(), and NetUIBase::lookupHost().

Referenced by VsnetHTTPSocket::lower_selected(), and VsnetHTTPSocket::VsnetHTTPSocket().

82 {
83  std::string dummy1, dummy2;
84  unsigned short port;
85 
86  std::string host;
87  hostFromURI( uri, host, dummy1, dummy2, port );
88  if (!port)
89  port = 80;
90  return NetUIBase::lookupHost( host.c_str(), port );
91 }

Variable Documentation

int errchance = 9

Definition at line 302 of file vsnet_sockethttp.cpp.

int NONBLOCKING_CONNECT

Definition at line 57 of file netui.cpp.

Referenced by NetUIBase::createClientSocket(), and VsnetHTTPSocket::lower_sendbuf().