| 6031 | } |
| 6032 | |
| 6033 | inline bool ClientImpl::handle_request(Stream &strm, Request &req, |
| 6034 | Response &res, bool close_connection, |
| 6035 | Error &error) { |
| 6036 | if (req.path.empty()) { |
| 6037 | error = Error::Connection; |
| 6038 | return false; |
| 6039 | } |
| 6040 | |
| 6041 | auto req_save = req; |
| 6042 | |
| 6043 | bool ret; |
| 6044 | |
| 6045 | if (!is_ssl() && !proxy_host_.empty() && proxy_port_ != -1) { |
| 6046 | auto req2 = req; |
| 6047 | req2.path = "http://" + host_and_port_ + req.path; |
| 6048 | ret = process_request(strm, req2, res, close_connection, error); |
| 6049 | req = req2; |
| 6050 | req.path = req_save.path; |
| 6051 | } else { |
| 6052 | ret = process_request(strm, req, res, close_connection, error); |
| 6053 | } |
| 6054 | |
| 6055 | if (!ret) { return false; } |
| 6056 | |
| 6057 | if (300 < res.status && res.status < 400 && follow_location_) { |
| 6058 | req = req_save; |
| 6059 | ret = redirect(req, res, error); |
| 6060 | } |
| 6061 | |
| 6062 | #ifdef CPPHTTPLIB_OPENSSL_SUPPORT |
| 6063 | if ((res.status == 401 || res.status == 407) && |
| 6064 | req.authorization_count_ < 5) { |
| 6065 | auto is_proxy = res.status == 407; |
| 6066 | const auto &username = |
| 6067 | is_proxy ? proxy_digest_auth_username_ : digest_auth_username_; |
| 6068 | const auto &password = |
| 6069 | is_proxy ? proxy_digest_auth_password_ : digest_auth_password_; |
| 6070 | |
| 6071 | if (!username.empty() && !password.empty()) { |
| 6072 | std::map<std::string, std::string> auth; |
| 6073 | if (detail::parse_www_authenticate(res, auth, is_proxy)) { |
| 6074 | Request new_req = req; |
| 6075 | new_req.authorization_count_ += 1; |
| 6076 | new_req.headers.erase(is_proxy ? "Proxy-Authorization" |
| 6077 | : "Authorization"); |
| 6078 | new_req.headers.insert(detail::make_digest_authentication_header( |
| 6079 | req, auth, new_req.authorization_count_, detail::random_string(10), |
| 6080 | username, password, is_proxy)); |
| 6081 | |
| 6082 | Response new_res; |
| 6083 | |
| 6084 | ret = send(new_req, new_res, error); |
| 6085 | if (ret) { res = new_res; } |
| 6086 | } |
| 6087 | } |
| 6088 | } |
| 6089 | #endif |
| 6090 |
nothing calls this directly
no test coverage detected