Question

I am designing a web application which is a tie in to my iPhone application. It sends massively large URLs to the web server (15000 about.) I was using NearlyFreeSpeech.net, but they only support URLS up to 2000 characters. I was wondering if anybody knows of web hosting that will support really large URLs? Thanks, Isaac

Edit: My program needs to open a picture in Safari. I could do this 2 ways:

  • send it base64 encoded in the URL and just echo the query parameters.
  • first POST it to the server in my application, then the server would send back a unique ID after storing the photo in a database, which I would append to a URL which I would open in Safari which retrieved the photo from the database and delete it from the database.

You see, I am lazy, and I know Mobile Safari can support URI's up to 80 000 characters, so I think this is a OK way to do it. If there is something really wrong with this, please tell me.

Edit: I ended up doing it the proper POST way. Thanks.

Was it helpful?

Solution

If you're sending 15,000 character long URLs, in all likelyhood:

alt text http://img16.imageshack.us/img16/3847/youredoingitwronga.jpg

Use something like an HTTP POST instead.

The limitations you're running up against aren't so much an issue with the hosts - it's more the fact that web servers have a limit for the length of a URL. According to this page, Apache limits you to around 4k characters, and IIS limits you to 16k by default.

OTHER TIPS

Although it's not directly answering your question, and there is no official maximum length of a URL, browsers and servers have practical limits - see http://www.boutell.com/newfaq/misc/urllength.html for some details. In short, since IE (at least some versions in use) doesn't support URLs over 2,083 characters, it's probably wise to stay below that length.

If you need to just open it in Safari, and the server doesn't need to be involved, why not use a data: URI?

Sending long URIs over the network is basically never the right thing to do. As you noticed, some web hosts don't support long URIs. Some proxy servers may also choke on long URLs, which means that your app might not work for users who are behind those proxies. If you ever need to port your app to a different browser, other browsers may not support URIs that long.

If you need to get data up to a server, use a POST. Yes, it's an extra round trip, but it will be much more reliable.

Also, if you are uploading data to the server using a GET request, then you are vulnerable to all kinds of cross-site request forgery attacks; basically, an attacker can trick the user into uploading, say, goatse to their account simply by getting them to click on a link (perhaps hidden by TinyURL or another URL shortening service, or just embedded as a link in a web page when they don't look closely at the URL they're clicking on).

You should never use GET for sending data to the server, beyond query parameters that don't actually change anything on the server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top