mirror of
https://github.com/yhirose/cpp-httplib
synced 2026-06-08 18:30:49 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c909ffa758 | |||
| ff5677ad19 | |||
| 8b1b31ac20 |
@@ -365,6 +365,27 @@ httplib::Client cli("http://localhost:8080");
|
||||
httplib::Client cli("https://localhost");
|
||||
```
|
||||
|
||||
### Error code
|
||||
|
||||
Here is the list of errors from `Result::error()`.
|
||||
|
||||
```c++
|
||||
enum Error {
|
||||
Success = 0,
|
||||
Unknown,
|
||||
Connection,
|
||||
BindIPAddress,
|
||||
Read,
|
||||
Write,
|
||||
ExceedRedirectCount,
|
||||
Canceled,
|
||||
SSLConnection,
|
||||
SSLLoadingCerts,
|
||||
SSLServerVerification,
|
||||
UnsupportedMultipartBoundaryChars
|
||||
};
|
||||
```
|
||||
|
||||
### GET with HTTP headers
|
||||
|
||||
```c++
|
||||
|
||||
@@ -745,8 +745,11 @@ public:
|
||||
bool operator==(std::nullptr_t) const { return res_ == nullptr; }
|
||||
bool operator!=(std::nullptr_t) const { return res_ != nullptr; }
|
||||
const Response &value() const { return *res_; }
|
||||
Response &value() { return *res_; }
|
||||
const Response &operator*() const { return *res_; }
|
||||
Response &operator*() { return *res_; }
|
||||
const Response *operator->() const { return res_.get(); }
|
||||
Response *operator->() { return res_.get(); }
|
||||
Error error() const { return err_; }
|
||||
|
||||
private:
|
||||
@@ -4735,7 +4738,7 @@ inline bool ClientImpl::read_response_line(Stream &strm, Response &res) {
|
||||
const static std::regex re("(HTTP/1\\.[01]) (\\d+) (.*?)\r\n");
|
||||
|
||||
std::cmatch m;
|
||||
if (!std::regex_match(line_reader.ptr(), m, re)) { return false; }
|
||||
if (!std::regex_match(line_reader.ptr(), m, re)) { return true; }
|
||||
res.version = std::string(m[1]);
|
||||
res.status = std::stoi(std::string(m[2]));
|
||||
res.reason = std::string(m[3]);
|
||||
|
||||
Reference in New Issue
Block a user