diff --git a/netwerk/base/src/ProxyAutoConfig.h b/netwerk/base/src/ProxyAutoConfig.h index 0f6e5090c9c..919ad5cbfde 100644 --- a/netwerk/base/src/ProxyAutoConfig.h +++ b/netwerk/base/src/ProxyAutoConfig.h @@ -44,7 +44,7 @@ public: * result = proxy-spec *( proxy-sep proxy-spec ) * proxy-spec = direct-type | proxy-type LWS proxy-host [":" proxy-port] * direct-type = "DIRECT" - * proxy-type = "PROXY" | "SOCKS" | "SOCKS4" | "SOCKS5" + * proxy-type = "PROXY" | "HTTP" | "HTTPS" | "SOCKS" | "SOCKS4" | "SOCKS5" * proxy-sep = ";" LWS * proxy-host = hostname | ipv4-address-literal * proxy-port = diff --git a/netwerk/base/src/nsProtocolProxyService.cpp b/netwerk/base/src/nsProtocolProxyService.cpp index 98ea68b7bb0..446e3093c1d 100644 --- a/netwerk/base/src/nsProtocolProxyService.cpp +++ b/netwerk/base/src/nsProtocolProxyService.cpp @@ -34,6 +34,7 @@ namespace mozilla { extern const char kProxyType_HTTP[]; + extern const char kProxyType_HTTPS[]; extern const char kProxyType_SOCKS[]; extern const char kProxyType_SOCKS4[]; extern const char kProxyType_SOCKS5[]; @@ -658,6 +659,7 @@ nsProtocolProxyService::CanUseProxy(nsIURI *aURI, int32_t defaultPort) // nsProxyInfo in order to compare by string pointer namespace mozilla { const char kProxyType_HTTP[] = "http"; +const char kProxyType_HTTPS[] = "https"; const char kProxyType_PROXY[] = "proxy"; const char kProxyType_SOCKS[] = "socks"; const char kProxyType_SOCKS4[] = "socks4"; @@ -687,11 +689,19 @@ nsProtocolProxyService::ExtractProxyInfo(const char *start, uint32_t len = sp - start; const char *type = nullptr; switch (len) { - case 5: - if (PL_strncasecmp(start, kProxyType_PROXY, 5) == 0) + case 4: + if (PL_strncasecmp(start, kProxyType_HTTP, 5) == 0) { type = kProxyType_HTTP; - else if (PL_strncasecmp(start, kProxyType_SOCKS, 5) == 0) + } + break; + case 5: + if (PL_strncasecmp(start, kProxyType_PROXY, 5) == 0) { + type = kProxyType_HTTP; + } else if (PL_strncasecmp(start, kProxyType_SOCKS, 5) == 0) { type = kProxyType_SOCKS4; // assume v4 for 4x compat + } else if (PL_strncasecmp(start, kProxyType_HTTPS, 5) == 0) { + type = kProxyType_HTTPS; + } break; case 6: if (PL_strncasecmp(start, kProxyType_DIRECT, 6) == 0) @@ -720,10 +730,13 @@ nsProtocolProxyService::ExtractProxyInfo(const char *start, start++; // port defaults - if (type == kProxyType_HTTP) + if (type == kProxyType_HTTP) { port = 80; - else + } else if (type == kProxyType_HTTPS) { + port = 443; + } else { port = 1080; + } nsProxyInfo *pi = new nsProxyInfo(); pi->mType = type; @@ -1163,6 +1176,7 @@ nsProtocolProxyService::NewProxyInfo(const nsACString &aType, { static const char *types[] = { kProxyType_HTTP, + kProxyType_HTTPS, kProxyType_SOCKS, kProxyType_SOCKS4, kProxyType_DIRECT @@ -1171,7 +1185,7 @@ nsProtocolProxyService::NewProxyInfo(const nsACString &aType, // resolve type; this allows us to avoid copying the type string into each // proxy info instance. we just reference the string literals directly :) const char *type = nullptr; - for (uint32_t i=0; iType() == kProxyType_HTTP) { + if ((iter->Type() == kProxyType_HTTP) || + (iter->Type() == kProxyType_HTTPS)) { // reject! if (last) last->mNext = iter->mNext; diff --git a/netwerk/base/src/nsProxyInfo.cpp b/netwerk/base/src/nsProxyInfo.cpp index 4e727c40282..1d96f320ff9 100644 --- a/netwerk/base/src/nsProxyInfo.cpp +++ b/netwerk/base/src/nsProxyInfo.cpp @@ -75,6 +75,7 @@ nsProxyInfo::SetFailoverProxy(nsIProxyInfo *proxy) // comparison of mType by string pointer is valid within necko namespace mozilla { extern const char kProxyType_HTTP[]; + extern const char kProxyType_HTTPS[]; extern const char kProxyType_SOCKS[]; extern const char kProxyType_SOCKS4[]; extern const char kProxyType_SOCKS5[]; @@ -95,6 +96,12 @@ nsProxyInfo::IsHTTP() return mType == kProxyType_HTTP; } +bool +nsProxyInfo::IsHTTPS() +{ + return mType == kProxyType_HTTPS; +} + bool nsProxyInfo::IsSOCKS() { diff --git a/netwerk/base/src/nsProxyInfo.h b/netwerk/base/src/nsProxyInfo.h index 550bbf2d3a2..e0a46eac29a 100644 --- a/netwerk/base/src/nsProxyInfo.h +++ b/netwerk/base/src/nsProxyInfo.h @@ -38,6 +38,7 @@ public: bool IsDirect(); bool IsHTTP(); + bool IsHTTPS(); bool IsSOCKS(); private: