code_app/sdk/webservice/HttpHead.h

45 lines
1.4 KiB
C
Raw Normal View History

#pragma once
#include "base/HGDef.h"
#include "base/HGInc.h"
#include <string>
#include <vector>
typedef std::pair<std::string, std::string> HttpPair;
typedef std::vector<HttpPair> HttpPairs;
class HttpHead
{
public:
HttpHead();
~HttpHead();
bool Parse(const std::string& head);
void Clear();
std::string GetRequestMethod() const;
std::string GetRequestURIPath() const;
HttpPairs GetRequestURIQueryInfos() const;
std::string GetRequestURIFragment() const;
std::string GetRequestHttpVersion() const;
HttpPairs GetHeadInfos() const;
int GetContentLength() const;
std::string GetContentType() const;
static std::string GetValue(const HttpPairs& infos, const std::string& key);
static void AnalysisURIQuery(const std::string& query, HttpPairs& queryInfos);
static void AnalysisURI(const std::string& uri, std::string& path, HttpPairs& queryInfos, std::string& fragment);
static void AnalysisHead(const std::string& head, std::string& requestMethod, std::string& requestURIPath,
HttpPairs& requestURIQueryInfos, std::string& requestURIFragment, std::string& httpVersion, HttpPairs& headInfos);
private:
static std::string AnalyURIString(const std::string& str);
private:
std::string m_requestMethod;
std::string m_requestURIPath;
HttpPairs m_requestURIQueryInfos;
std::string m_requestURIFragment;
std::string m_requestHttpVersion;
HttpPairs m_headInfos;
};