HTTP request over IPv6

大兔子大兔子 提交于 2019-12-12 18:20:16

问题


I want to know the difference between the header format of HTTP GET request that uses from IPv4 server to IPv6 server?

Now, currently I am using the following format:

"GET /"+myFileToDownLoad+" HTTP/1.1\r\n"+
            "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*\r\n"
            +"Referer: http://"+myDstIp+"/\r\n"
            +"Accept-Language: he\r\n"
            +"Accept-Encoding: gzip, deflate\r\n"
            +"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n"
            //+"Host: "+myDstIp+"\r\n"
            +"Host: "+((myHost==null)?myDstIp:myHost)+"\r\n"
            +"Connection: Close\r\n\r\n";

So, if i want to use the IPv6 server, is it necessary to change the format?


回答1:


RFC 2732 updates the Host field:

The following changes to the syntax in RFC 2396 are made: (1) change the 'host' non-terminal to add an IPv6 option:

  host          = hostname | IPv4address | IPv6reference
  ipv6reference = "[" IPv6address "]"

where IPv6address is defined as in RFC2373 [ARCH].

So you should enclose IPv6 address in square brackets.

Update: The change applies to URLs with host part in IPv6 format and propagates to all request fields that use 'host' part from the original address - in your example these are Host and Referrer. That is, you'll have to add square brackets around myDstIp in Referrer and Host fields.




回答2:


RFC2396 Uniform Resource Identifiers (URI): Generic Syntax was updated by RFC2732 Format for Literal IPv6 Addresses in URL's.

Specifically, section 3 in RFC2732.



来源:https://stackoverflow.com/questions/7468782/http-request-over-ipv6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!