瀏覽代碼

return error code on 407 proxy authenticate

David Rose 23 年之前
父節點
當前提交
c70c892c2a
共有 2 個文件被更改,包括 17 次插入1 次删除
  1. 16 1
      panda/src/downloader/downloader.cxx
  2. 1 0
      panda/src/express/error_utils.h

+ 16 - 1
panda/src/downloader/downloader.cxx

@@ -779,8 +779,10 @@ parse_http_response(const string &resp) {
         downloader_cat.debug()
         downloader_cat.debug()
           << "Downloader::parse_http_response() - got a 302 redirect"
           << "Downloader::parse_http_response() - got a 302 redirect"
           << endl;
           << endl;
-      return EU_http_redirect;
+      return EU_error_abort;
       break;
       break;
+    case 407:
+      return EU_error_http_proxy_authentication;
     case 408:
     case 408:
       return EU_error_http_server_timeout;
       return EU_error_http_server_timeout;
     case 503:
     case 503:
@@ -821,6 +823,7 @@ parse_header(DownloadStatus *status) {
   string bufstr((char *)status->_start, status->_bytes_in_buffer);
   string bufstr((char *)status->_start, status->_bytes_in_buffer);
   size_t p  = 0;
   size_t p  = 0;
   bool redirect = false;
   bool redirect = false;
+  bool authenticate = false;
   while (p < bufstr.length()) {
   while (p < bufstr.length()) {
     // Server sends out CR LF (\r\n) as newline delimiter
     // Server sends out CR LF (\r\n) as newline delimiter
     size_t nl = bufstr.find("\015\012", p);
     size_t nl = bufstr.find("\015\012", p);
@@ -849,6 +852,9 @@ parse_header(DownloadStatus *status) {
             << "Downloader::parse_header() - Header is valid: "
             << "Downloader::parse_header() - Header is valid: "
             << component << endl;
             << component << endl;
         status->_header_is_valid = true;
         status->_header_is_valid = true;
+      } else if (parse_ret == EU_error_http_proxy_authentication) {
+        authenticate = true;
+        status->_header_is_valid = true;
       } else if (parse_ret == EU_http_redirect) {
       } else if (parse_ret == EU_http_redirect) {
         redirect = true;
         redirect = true;
         status->_header_is_valid = true;
         status->_header_is_valid = true;
@@ -896,6 +902,12 @@ parse_header(DownloadStatus *status) {
         return EU_error_abort;
         return EU_error_abort;
       }
       }
 
 
+    } else if (authenticate && tline == "Proxy-Authenticate") {
+      // We don't presently support authentication-demanding proxies.
+      downloader_cat.warning()
+        << tline << "\n";
+      return EU_error_http_proxy_authentication;
+
     } else if (redirect == true && tline == "Location") {
     } else if (redirect == true && tline == "Location") {
       tline = component.substr(cpos + 1, string::npos);
       tline = component.substr(cpos + 1, string::npos);
       downloader_cat.error()
       downloader_cat.error()
@@ -912,6 +924,9 @@ parse_header(DownloadStatus *status) {
           << "Location directive" << endl;
           << "Location directive" << endl;
         return EU_error_abort;
         return EU_error_abort;
       }
       }
+      if (authenticate) {
+        return EU_error_http_proxy_authentication;
+      }
       if (downloader_cat.is_spam())
       if (downloader_cat.is_spam())
         downloader_cat.spam()
         downloader_cat.spam()
           << "Downloader::parse_header() - Header is complete" << endl;
           << "Downloader::parse_header() - Header is complete" << endl;

+ 1 - 0
panda/src/express/error_utils.h

@@ -73,6 +73,7 @@ enum ErrorUtilCode {
   EU_error_http_server_timeout = -70,
   EU_error_http_server_timeout = -70,
   EU_error_http_gateway_timeout = -71,
   EU_error_http_gateway_timeout = -71,
   EU_error_http_service_unavailable = -72,
   EU_error_http_service_unavailable = -72,
+  EU_error_http_proxy_authentication = -73,
 
 
   // Zlib errors
   // Zlib errors
   EU_error_zlib = -80,
   EU_error_zlib = -80,