HttpRequest::HttpRequest(const std::string& uri, const HttpMethod method, const std::string& body)
{
	SetUri(uri);
	SetHttpVersion(HttpVersion(1, 0));
	this->method = method;
	this->body = body;
}
示例#2
0
HttpVersion HttpVersion::fromString(const QString & string)
{
    if (!string.startsWith("HTTP/"))
    {
        return HttpVersion();
    }
    QString version = string.mid(5);
    int pos = version.indexOf('.');
    if (pos<0)
    {
        return HttpVersion();
    }
    unsigned _major = version.left(pos).toUInt();
    unsigned _minor = version.mid(pos + 1).toUInt();

    return HttpVersion(_major, _minor);
}
示例#3
0
bool HttpMessage::IsKeepAlive() const {
    const std::string* alive;
    if (!GetHeader("Connection", &alive)) {
        if (m_version < HttpVersion(1, 1)) {
            return false;
        }
        return true;
    }
    return strcasecmp(alive->c_str(), "keep-alive") == 0;
}
示例#4
0
bool HttpMessage::ParseVersion(const std::string& version_str)
{
    if (!StringStartsWith(version_str, "HTTP/"))
        return false;
    const std::string& ver = version_str.substr(5);
    int major, minor;
    if (StringScan(ver, "%d.%d", &major, &minor) != 2)
        return false;
    SetVersion(HttpVersion(major, minor));
    return true;
}
示例#5
0
HttpMessage::HttpMessage()
    : m_httpVersion(HttpVersion(1, 1))
{
}