关于URL最大长度限制的相关资料查证,url查证
关于URL最大长度限制的相关资料查证,url查证
在开发调试支付宝接口时,突然发现支付宝接口的URL很长,远远大于之前自己印象中的255个字符。赶紧搜索查证了一番,理解如下:
URL不能大于255bytes的说法确实存在,在RFC2616中提到:
复制代码 代码如下:
The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).
Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.
从上一点也可以看出,255bytes的说法也是为了兼容性考虑。实际上现代浏览器的限制如下:
复制代码 代码如下:
Microsoft Internet Explorer (Browser)
Microsoft states that the maximum length of a URL in Internet Explorer is 2,083 characters, with no more than 2,048 characters in the path portion of the URL. In my tests, attempts to use URLs longer than this produced a clear error message in Internet Explorer.
Firefox (Browser)
After 65,536 characters, the location bar no longer displays the URL in Windows Firefox 1.5.x. However, longer URLs will work. I stopped testing after 100,000 characters.
Safari (Browser)
At least 80,000 characters will work. I stopped testing after 80,000 characters.
Opera (Browser)
At least 190,000 characters will work. I stopped testing after 190,000 characters. Opera 9 for Windows continued to display a fully editable, copyable and pasteable URL in the location bar even at 190,000 characters.
Apache (Server)
My early attempts to measure the maximum URL length in web browsers bumped into a server URL length limit of approximately 4,000 characters, after which Apache produces a “413 Entity Too Large” error. I used the current up to date Apache build found in Red Hat Enterprise Linux 4. The official Apache documentation only mentions an 8,192-byte limit on an individual field in a request.
Microsoft Internet Information Server
The default limit is 16,384 characters (yes, Microsoft's web server accepts longer URLs than Microsoft's web browser). This is configurable.
Perl HTTP::Daemon (Server)
Up to 8,000 bytes will work. Those constructing web application servers with Perl's HTTP::Daemon module will encounter a 16,384 byte limit on the combined size of all HTTP request headers. This does not include POST-method form data, file uploads, etc., but it does include the URL. In practice this resulted in a 413 error when a URL was significantly longer than 8,000 characters. This limitation can be easily removed. Look for all occurrences of 16×1024 in Daemon.pm and replace them with a larger value. Of course, this does increase your exposure to denial of service attacks.
另外值得注意的是,有文章提到作为的href属性时,URL不能超过1024bytes,这点没有详细查证
综上,URL还是不适合太长,不是不得已,尽量不要通过GET方式提交大量参数,可以考虑用POST方式(大约在2M左右,应该是和服务器及设定有关)。另外这么长的URL在访问和收藏(有文章提到有些浏览器在收藏超长地址时也是会出现问题)时也是相当不友好的。当然,之前数据库字段设置时还是作为255bytes处理,现在可能要考虑扩充一下了。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

報錯的原因NameResolutionError(self.host,self,e)frome是由urllib3函式庫中的例外類型,這個錯誤的原因是DNS解析失敗,也就是說,試圖解析的主機名稱或IP位址無法找到。這可能是由於輸入的URL位址不正確,或DNS伺服器暫時無法使用所導致的。如何解決解決此錯誤的方法可能有以下幾種:檢查輸入的URL地址是否正確,確保它是可訪問的確保DNS伺服器可用,您可以嘗試在命令行中使用"ping"命令來測試DNS伺服器是否可用嘗試使用IP位址而不是主機名稱來存取網站如果是在代理

PHP函數介紹—get_headers():取得URL的回應頭資訊概述:在PHP開發中,我們經常需要取得網頁或遠端資源的回應頭資訊。 PHP函數get_headers()能夠方便地取得目標URL的回應頭訊息,並以陣列形式傳回。本文將介紹get_headers()函數的用法,以及提供一些相關的程式碼範例。 get_headers()函數的用法:get_header

區別:1、定義不同,url是是統一資源定位符,而html是超文本標記語言;2、一個html中可以有很多個url,而一個url中只能存在一個html頁面;3、html指的是網頁,而url指的是網站位址。

現在許多熱愛遊戲的windows用戶都進入了Steam客戶端,可以搜尋、下載和玩任何好遊戲。但是,許多用戶的個人資料可能具有完全相同的名稱,這使得查找個人資料或甚至將Steam個人資料連結到其他第三方帳戶或加入Steam論壇以共享內容變得困難。為設定檔分配了一個唯一的17位id,它保持不變,用戶無法隨時更改,而用戶名或自訂URL可以更改。無論如何,有些用戶並不知道他們的Steamid,這對於了解這一點非常重要。如果您也不知道如何找到您帳戶的Steamid,請不要驚慌。在這篇文

使用url進行編碼和解碼編碼和解碼的類別java.net.URLDecoder.decode(url,解碼格式)解碼器.解碼方法。轉換成普通字串,URLEncoder.decode(url,編碼格式)將普通字串變成指定格式的字串packagecom.zixue.springbootmybatis.test;importjava.io.UnsupportedEncodingException;importjava.net.URLDecoder;importjava.net. URLEncoder

前言在某些情況下,服務的controller中前綴是一致的,例如所有URL的前綴都為/context-path/api/v1,需要為某些URL加上統一的前綴。能想到的處理辦法為修改服務的context-path,在context-path中加上api/v1,這樣修改全域的前綴能夠解決上面的問題,但存在弊端,如果URL存在多個前綴,例如有些URL需要前綴為api/v2,就無法區分了,如果服務中的一些靜態資源不想添加api/v1,也無法區分。下面透過自訂註解的方式實現某些URL前綴的統一添加。一、

Scrapy是一個功能強大的Python爬蟲框架,可用於從網路上取得大量的資料。但是,在進行Scrapy開發時,經常會遇到重複URL的爬取問題,這會浪費大量的時間和資源,影響效率。本文將介紹一些Scrapy優化技巧,減少重複URL的爬取,提升Scrapy爬蟲的效率。一、使用start_urls和allowed_domains屬性在Scrapy爬蟲中,可

Nginx重寫URL設定實戰,優化網站架構與SEO引言:在現代網路時代,傳統的靜態網頁已經無法滿足使用者的需求。為了提供更好的使用者體驗,許多網站開始採用動態網頁技術。但是,動態網頁的URL往往不夠友好,對於搜尋引擎的收錄和使用者分享都存在著一定的困難。本文將介紹如何使用Nginx的URL重寫功能,來最佳化網站的架構和SEO。一、Nginx的URL重寫功能Nginx
