PIHTTP::MessageConst code categories
PIHTTPClient migrated to curl_multi_api
This commit is contained in:
@@ -18,7 +18,7 @@ enum class Method {
|
||||
};
|
||||
|
||||
enum class Code {
|
||||
Unknown,
|
||||
Unknown = -1,
|
||||
Continue = 100,
|
||||
SwitchingProtocols = 101,
|
||||
Processing = 102,
|
||||
|
||||
@@ -18,6 +18,35 @@ const char * PIHTTP::methodName(Method m) {
|
||||
}
|
||||
|
||||
|
||||
// PIHTTP::MessageConst
|
||||
|
||||
bool PIHTTP::MessageConst::isCodeInformational() const {
|
||||
return (int)code() >= 100 && (int)code() < 200;
|
||||
}
|
||||
|
||||
|
||||
bool PIHTTP::MessageConst::isCodeSuccess() const {
|
||||
return (int)code() >= 200 && (int)code() < 300;
|
||||
}
|
||||
|
||||
|
||||
bool PIHTTP::MessageConst::isCodeRedirection() const {
|
||||
return (int)code() >= 300 && (int)code() < 400;
|
||||
}
|
||||
|
||||
|
||||
bool PIHTTP::MessageConst::isCodeClientError() const {
|
||||
return (int)code() >= 400 && (int)code() < 500;
|
||||
}
|
||||
|
||||
|
||||
bool PIHTTP::MessageConst::isCodeServerError() const {
|
||||
return (int)code() >= 500 && (int)code() < 600;
|
||||
}
|
||||
|
||||
|
||||
// PIHTTP::MessageMutable
|
||||
|
||||
PIHTTP::MessageMutable & PIHTTP::MessageMutable::addHeader(const PIString & header, const PIString & value) {
|
||||
m_headers[header] = value;
|
||||
return *this;
|
||||
|
||||
@@ -13,6 +13,12 @@ class PIP_EXPORT MessageConst {
|
||||
public:
|
||||
PIHTTP::Method method() const { return m_method; }
|
||||
PIHTTP::Code code() const { return m_code; }
|
||||
bool isCodeInformational() const;
|
||||
bool isCodeSuccess() const;
|
||||
bool isCodeRedirection() const;
|
||||
bool isCodeClientError() const;
|
||||
bool isCodeServerError() const;
|
||||
bool isCodeError() const { return isCodeClientError() || isCodeServerError(); }
|
||||
const PIString & path() const { return m_path; }
|
||||
PIStringList pathList() const { return m_path.split('/').removeAll({}); }
|
||||
const PIByteArray & body() const { return m_body; }
|
||||
|
||||
Reference in New Issue
Block a user