We must add ssh on it? Something like:
Code: Alles auswählen
eHTTPSConnection *eHTTPSConnection::doRequest(const char *uri, eMainloop *ml, int *error)
{
if (error)
*error=0;
char *defaultproto="https";
eString proto, host, path;
int port=443;
int state=0; // 0 proto, 1 host, 2 port 3 path
while (*uri)
{
switch (state)
{
case 0:
if (!strncmp(uri, "://", 3))
{
state=1;
uri+=3;
} else if ((*uri=='/') || (*uri==':'))
{
host=proto;
state=1;
proto=defaultproto;
} else
proto.push_back(*uri++);
break;
case 1:
if (*uri=='/')
state=3;
else if (*uri==':')
{
state=2;
port=0;
uri++;
} else
host.push_back(*uri++);
break;
case 2:
if (*uri=='/')
state=3;
else
{
if (!isdigit(*uri))
{
port=-1;
state=3;
} else
{
port*=10;
port+=*uri++-'0';
}
}
break;
case 3:
path.push_back(*uri++);
}
}
if (state==0)
{
path=proto;
proto=defaultproto;
}
#ifdef DEBUG_HTTPD
eDebug("proto: '%s', host '%s', path '%s', port '%d'", proto.c_str(), host.c_str(), path.c_str(), port);
#endif
if (!host.size())
{
eDebug("no host given");
if (error)
*error=ENOENT;
return 0;
}
if (strcmp(proto.c_str(), "https"))
{
eDebug("invalid protocol (%s)", proto.c_str());
if (error)
*error=EINVAL;
return 0;
}
if (port == -1)
{
eDebug("invalid port");
if (error)
*error=EINVAL;
return 0;
}
if (!path.size())
path="/";
eHTTPSConnection *c=new eHTTPSConnection(ml);
c->request="GET";
c->requestpath=path.c_str();
c->httpversion="HTTP/1.0";
c->local_header["Host"]=host;
if ((*error=c->connectToHost(host, port))) // already deleted by error
return 0;
return c;
}