gpt4 book ai didi

java - Android 中的 HTTP POST,URL 中带有下划线

转载 作者:太空狗 更新时间:2023-10-29 14:11:52 28 4
gpt4 key购买 nike

我在其他帖子中看到带有下划线的 URL 不适用于此代码。这是因为主机名中不允许使用下划线:

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.my_page.com");

但是有没有其他方法可以避免这个错误,或者这是不可能的?我还没有在其他帖子中找到这个问题的解决方案。

最佳答案

来自 http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names

Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label must be between 1 and 63 characters long,[2] and the entire hostname (including the delimiting dots but not a trailing dot) has a maximum of 253 ASCII characters.[3]

The Internet standards for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted.

While a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore.

或来自 http://domainkeys.sourceforge.net/underscore.html

Underscores allowed, except in host names

Host names are not allowed to have underscores in them. In DNS, host names are the name fields of A or MX records or the data fields of the SOA and NS records. Thus, there are many DNS entries that are not hostnames.

总结:您不能在主机名中使用下划线。你也不应该想要。

关于java - Android 中的 HTTP POST,URL 中带有下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27048949/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com