Skip to main content

App Engine: Fixing “414 URI Too Long” by Posting Data Correctly

I've been working on an applciation utilizing Google's App Engine. The first version of my application sent about 500 bytes of information along with each user POST request. The second version upped this to around 100 bytes and the App Engine server started giving the error:


Requested URI too long: ... HTTP/1.1" 414 –


This is the http error returned when a post request is longer than the server is configured to accept. After a little research I found this excellent article:

http://www.openjs.com/articles/ajax_xmlhttp_using_post.php

that solved my problem. The short version of the article is:

Don’t send the post parameters as part of the url, send them using the XMLHTTP object’s send method once the object has been opened using only the address, (everything before the ?), of the original post url.

So, the original code that looked like:


var my_url = "/myhandler?longstring=" +

encodeURIComponent(longstring) +

//Now send the string to the db

if (typeof XMLHttpRequest != "undefined") {

req = new XMLHttpRequest();

} else if (window.ActiveXObject) {

req = new ActiveXObject("Microsoft.XMLHTTP");

}

req.open("POST", my_url, true);

req.onreadystatechange = my_cb;

req.send(null);


Becomes code that looks like:


var my_url = "longstring=" +

encodeURIComponent(longstring) +

//Now send the string to the db

if (typeof XMLHttpRequest != "undefined") {

req = new XMLHttpRequest();

} else if (window.ActiveXObject) {

req = new ActiveXObject("Microsoft.XMLHTTP");

}

req.open("POST", '/myhandler', true);

req.setRequestHeader("Content-type",

"application/x-www-form-urlencoded");

req.setRequestHeader("Content-length", score_params.length);

req.setRequestHeader("Connection", "close");

req.onreadystatechange = log_scores_cb;

req.send(score_params);

Notice that the call to send was changed from a null argument to the POST command arguments sent in the original URL. Also notice that the length of the parameters was sent to the server ahead of time in the 'Content-length' header.

In contrast to this 414 fix—where we avoid long URLs—here’s a case where we intentionally use long URLs to store state (with guardrails): [Using URLs to Store Web App State in Cesium Sandcastle]











Comments

Popular posts from this blog

How Many Files Can You Add to a GPT Project? An Interview with GPT-5 on Limits, Context Engineering Tips, and Chats

 Setting the scene: I’m tinkering with Project TouCans, knee-deep in radio logs, SQLite dumps, and Cesium code. Naturally, I’m wondering if shoving all this into one GPT Project is a recipe for brilliance… or for disaster. So I turn to Vril — you know, after Brainy from the Legion of Super-Heroes , because what else do you call your AI sidekick who always has the answers? Time to ask him straight up. [ As an aside, yes, GPT-5 has decided to sometimes call me Vail. I'm not sure why to be honest. Also, I asked Vril, er GPT-5, to write up our interview for me. Apparently, me asking it to 'Bro' up a few stories, just for fun, has convinced Vril that I use 'Like,' more than I actually might. ] Me (Vail): So Vril, how many files can I throw into a GPT Project before it just starts choking? Like, is there some magic number where the context window taps out and everything falls apart? GPT-5 (Vril): Great question. There’s no single hard file limit. What matters is ...

The Alcubierre Warp Drive Tophat Function and Open Science with Sage

I transferred yesterday's Mathematica file with the Alcubierre warp drive[2] line element and space curvature calculations to the  +Sage Mathematical Software System  today, (the files been  added to the public repository [3]).  If you haven't used Sage before, it's a Python based software package that's similar in functionality to Mathematica.  Oh, and it' free.  I also worked a little more on understanding the theory, but frankly, I made far more progress with the software than the theory.  What follows will be a little more of the Alcubierre theory, plus, a cool Sage interactive demo of one of the Alcubierre functions[1], as well as a bit about my first experience with using Sage. Theory The theory is fun, but it's moving slowly.  Here's the chalk board from this morning's discussion Alcubierre setup the derivation using something called the 3+1 formalism which means we consider space to be flat, (in this case), slices that are labelled ...

When Codex CLI Met Port 9 (Debugging WinError 10061 in a Whisper Pipeline)

When Port 9 Ate My Transcript When Port 9 Ate My Transcript A small debugging story about proxies, Codex CLI, and why localhost isn’t always your friend. CopaseticFlow field notes WinError 10061 Codex CLI + Whisper Environment gremlins There’s a particular kind of bug that feels like someone's been messing with your network stack again. You run a script from cmd.exe . It works. You run the exact same script from Codex CLI. It stops with: [WinError 10061] No connection could be made because the target machine actively refused it FFmpeg happily splits the audio. The Whisper API call dies immediately. No 401. No timeout. Just an instant refusal. Translation: that’s not an API error. That’s a socket being rejected. ...