Https 发送到HTTP代理服务器的正确URL格式是什么?

Https 发送到HTTP代理服务器的正确URL格式是什么?,https,proxy,http-redirect,Https,Proxy,Http Redirect,当我的应用程序从服务器(通过https)请求特定URL时,它会得到一个永久重定向。但是,位置标头的格式不正确。我看到这样的情况: > GET https://myserver/url HTTP/1.1 < 301 Moved Permanently < Location: https://redirectedserverhttp://myserver/url Wget甚至在其源代码中有一条注释: /* When using SSL over proxy, CONNECT es

当我的应用程序从服务器(通过https)请求特定URL时,它会得到一个永久重定向。但是,位置标头的格式不正确。我看到这样的情况:

> GET https://myserver/url HTTP/1.1
< 301 Moved Permanently
< Location: https://redirectedserverhttp://myserver/url
Wget甚至在其源代码中有一条注释:

/* When using SSL over proxy, CONNECT establishes a direct
   connection to the HTTPS server.  Therefore use the same
   argument as when talking to the server directly. */

这是某个地方定义的实际标准吗?如果应该使用绝对URI表单,为什么其他工具不使用它,为什么它失败了?

通常,每个http请求都会发送一个http头。
下面是一个使用opera dragonfly工具构建的示例:

答复:

HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Sun, 24 Nov 2013 01:38:41 GMT
Etag: "359670651"
Expires: Sun, 01 Dec 2013 01:38:41 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (mia/41C4)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 1270

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 50px;
        background-color: #fff;
        border-radius: 1em;
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
        @media (max-width: 700px) {
            body {
                background-color: #fff;
            }
            div {
                width: auto;
                margin: 0 auto;
                border-radius: 0;
                padding: 1em;
            }
        }
        </style>    
    </head>

    <body>
        <div>
            <h1>Example Domain</h1>
            <p>This domain is established to be used for illustrative examples in documents.   You may use this
        domain in examples without prior coordination or asking for permission.</p>
            <p><a href="http://www.iana.org/domains/example">More information...</a></p>
        </div>
    </body>
</html>
HTTP/1.1200正常
接受范围:字节
缓存控制:最大年龄=604800
内容类型:text/html
日期:2013年11月24日星期日01:38:41 GMT
Etag:“359670651”
过期时间:2013年12月1日星期日01:38:41 GMT
最后修改:2013年8月9日星期五23:54:35 GMT
服务器:ECS(mia/41C4)
X缓存:命中
x-ec-custom-error:1
内容长度:1270
示例域
身体{
背景色:#F0F2;
保证金:0;
填充:0;
字体系列:“开放式Sans”、“Helvetica Neue”、Helvetica、Arial、Sans serif;
}
div{
宽度:600px;
保证金:5em自动;
填充:50px;
背景色:#fff;
边界半径:1米;
}
a:链接,a:已访问{
颜色:#38488f;
文字装饰:无;
}
@介质(最大宽度:700px){
身体{
背景色:#fff;
}
div{
宽度:自动;
保证金:0自动;
边界半径:0;
填充:1em;
}
}
示例域
此域用于文档中的说明性示例。你可以用这个
未经事先协调或请求许可,示例中的域


由于所有浏览器都会以相对路径发送请求,代理开发人员可能会认为不值得为标准的这一部分操心…

您只发送带有HTTP的绝对URL。无论如何,它们对于HTTPS都是无用的,因为代理无法看到它们。它只看到
CONNECT
标题,其他所有内容都是加密的


不是代理用无效URL响应,而是服务器本身。代理无法查看或响应,因为它也是加密的。

如果您在网络接口上侦听流量,您将看到头中几乎所有http GET请求都使用相对路径而不是完整路径。代替使用完整路径,您应该考虑使用HTTP(S)报头中的主机行(请在我不手动检查答案的情况下通知@ ME)。@ USER 22547070:在与代理交谈时,当使用SSL时,我试图找出协议。网络嗅探器不会告诉我任何事情,因为数据包是加密的。是的,但是你可以看到http的结果。另外,通过
我试图在与代理交谈时使用SSL时找出协议,您的意思是想让代理检测协议是否为sftp而不是https吗?例如,在HTTP和https情况下,我都发送
GET https://
,但对于https,代理使用无效的重定向URL进行响应。如果我将其更改为
GET/
,它会工作,但根据RFC,我的也会工作。我正在尝试找出是否应该将代码更改为我列出的
if(proxy&&!https)
或者我的代码是否正确,而这个特定的代理是否错误。这并不能回答我的问题。我知道我可以通过发送
/url
而不是
http://host/url
但我需要知道这是否是一个很好的解决问题的通用解决方案,或者它是否会修复此代理并破坏许多其他代理。@GraemePerrow:如果代理不支持相对路径,这意味着没有一个web浏览器不能使用它,因为他们使用Http头中的
主机:
,而不是完整路径。因此,它不应该破坏其他代理…@user2284570:当向代理()发出请求时,需要使用absoluteURI表单,这一点非常好。所以我需要在使用HTTP通过代理连接时发送绝对URL,否则发送相对URL。谢谢
/* When using SSL over proxy, CONNECT establishes a direct
   connection to the HTTPS server.  Therefore use the same
   argument as when talking to the server directly. */
GET / HTTPS/1.1
Host: example.org
User-Agent: Opera/9.80 (X11; Linux x86_64; Edition Next) Presto/2.12.378 Version/12.50
Accept: text/html, application/xml;q=0.9, application/xhtml xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: en
Accept-Charset: iso-8859-1, utf-8, utf-16, utf-32, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Connection: Keep-Alive, TE
TE: deflate, gzip, chunked, identity, trailers
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Sun, 24 Nov 2013 01:38:41 GMT
Etag: "359670651"
Expires: Sun, 01 Dec 2013 01:38:41 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (mia/41C4)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 1270

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 50px;
        background-color: #fff;
        border-radius: 1em;
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
        @media (max-width: 700px) {
            body {
                background-color: #fff;
            }
            div {
                width: auto;
                margin: 0 auto;
                border-radius: 0;
                padding: 1em;
            }
        }
        </style>    
    </head>

    <body>
        <div>
            <h1>Example Domain</h1>
            <p>This domain is established to be used for illustrative examples in documents.   You may use this
        domain in examples without prior coordination or asking for permission.</p>
            <p><a href="http://www.iana.org/domains/example">More information...</a></p>
        </div>
    </body>
</html>