标签云

微信群

扫码加入我们

WeChat QR Code

在不同的浏览器中的URL的最大长度是多少?

What is the maximum length of a URL in different browsers? Does it differ among browsers?

Does the HTTP protocol dictate it?


FWIW, for Windows users, server paths exceeding 250 characters may cause grief when building URLs, for example, see HttpContext.Current.Server.MapPath fails for long file names at forums.asp.net. bottom line: if one restriction does not get you, another one may.

2018年06月20日15分18秒

From support.microsoft.com/kb/208427 "Maximum URL length is 2,083 characters in Internet Explorer"

2018年06月19日15分18秒

May I ask why did you need to know that? I.e. what's the use-case for having a long URL?

2018年06月19日15分18秒

Lohoris: If a form uses get rather than post, then bookmarking the page reached by the filled-in form will capture the information that was entered. In some cases, that can be bad, but in other cases it can be useful. For that to work, however, the browser has to be able to handle a URL containing all the information.

2018年06月20日15分18秒

Lohoris When we write pages to generate reports we used a criteria form. It is useful on some reports to be able to email the url to someone with the criteria built in. Depending on the report we are at times forced to use post or the criteria gets truncated. Just another use case.

2018年06月20日15分18秒

Note that IE11 won't bookmark URLs longer than 260 characters. I'm unsure if Edge has the same limitation.

2018年06月19日15分18秒

Today IE11 cuts my URL to 2048 chars.

2018年06月19日15分18秒

what about Edge, Firefox & Chrome? IE is now basically extinct around here...

2018年06月20日15分18秒

in Chrome in 2016 I've been able to open a url with 260300 ascii chars using the osx open command from a simple script, and could confirm that all the characters were passed through to the server. The url in the browser gets truncated to 32791 characters, concludinding with ... (%E2%80%A6%E2%80%A6)

2018年06月19日15分18秒

Paul Dixon It's really nice to see people that are willing to go above and beyond in answering questions on this site. Obviously people are showing their gratitude with the current upvote count being 3734, but I wanted to say thanks! :)

2018年06月19日15分18秒

He's talking about the fact that a base64 encoded jpeg is technically a URL, because it's specified as data:*. While he's correct in stating that it is a valid URL, I don't think that's what the question was asking.

2018年06月19日15分18秒

For the curious jsfiddle.net/SJjJb/828

2018年06月19日15分18秒

... or just paste it in your address bar.

2018年06月19日15分18秒

That is a URI not a URL.

2018年06月20日15分18秒

Because a data URL contains the protocol "data:", and the identifier, it's everything you need to LOCATE that "file" (even if the "Filesystem" is the space of all possible files). It is therefore a URL, which is also a URI. (But definitely not "not a URL")

2018年06月19日15分18秒

So, in effect, my assumption of 512 chars is largely wrong ^_^ Thanks for the test. I will never care about the query param length anymore..

2018年06月19日15分18秒

This should be the accepted answer... the first one doesn't actually provide hard limits for each browser which is what the questions asks for.

2018年06月20日15分18秒

Might be worth looking into Safari too. Safari is the only browser that does not support client-generated downloads. The workarounds are: a) open a BLOB URI (a short, temporary URI that points to an in-memory Blob) in a new window, b) open a base-64 encoded data URI in a new window (may be very long, but supports mime typing). Details here: github.com/eligrey/FileSaver.js/issues/12

2018年06月19日15分18秒

If the instability is around 65k it is probably right there near 65535 (2^16 - 1). Maybe they loop through chars using short i? Just a thought. I wonder what URL they tested for 65k+ o_o;;

2018年06月20日15分18秒

This answers is maybe the one that should be accepted, as it provides the concrete answers: 2k for IE, 65k for Safari/Firefox, "more" for Opera.

2018年06月20日15分18秒

I'm curious. Is the 65k URL a data scheme URI or really a URL in the classic sense?

1970年01月01日00分03秒

You sir deserve a +1 just for the effort of trying a 300MB URL

2018年06月19日15分18秒

iOS isn't a browser in and of itself. Was this in Safari for iOS?

2018年06月19日15分18秒

Randall schemes are handled by the OS and then dispatched to the app that can open them. So all apps on iOS, including Safari, can handle long URI.

2018年06月19日15分18秒

Thanks for the clarification. Presumably, though, this doesn't prevent an arbitrary app (say, eg, a Tor-powered browser) from introducing its own length restriction, correct?

2018年06月20日15分18秒

I wonder where "78" comes from? Maybe that original 1999 article was written under the assumption that people are reading their email in 80x24 terminal windows? Still, good advice!

2018年06月20日15分18秒

Well. IBM punch cards were also 80 columns. With two characters taken up by a carriage return and a line feed you get 78.

2018年06月19日15分18秒

Haha. :-) I was actually considering referencing 1981-era 80x25 CGA monitors in my comment, but you reached even further back! ...I wasn't around for the punch card era, but were they 80 bytes across, or only 80 bits?

2018年06月19日15分18秒

Not exactly a byte (8 bits). It encoded one character in each column.

2018年06月19日15分18秒

JonSchneider - 78 is quite specific, and may relate to readability of text (from a usability perspective given Nielsen's background), which is best between 50-60, and a maximum of 75.

2018年06月20日15分18秒

The variation between Internet Explorer and IIS makes sense when you consider that not all requests to a web server are done via a browser.

2018年06月19日15分18秒

Because SharePoint exposes web URLs as file paths, it runs into a separate limitation: the Windows file path length limit of 260 characters (or 248 characters when using an API). For more details about this limit, check out the "Maximum Path Length Limitation" section here: msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

2018年06月19日15分18秒