Mercurial > urweb
changeset 1691:ea292bf9431f
Avoid URL size limit in RPCs with large arguments
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 03 Mar 2012 16:41:20 -0500 |
parents | a7b70c7b3f1a |
children | a1a1d66aebac |
files | lib/js/urweb.js src/cjr_print.sml |
diffstat | 2 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/js/urweb.js Sat Mar 03 16:20:54 2012 -0500 +++ b/lib/js/urweb.js Sat Mar 03 16:41:20 2012 -0500 @@ -1137,10 +1137,17 @@ } } -function requestUri(xhr, uri, needsSig) { +function requestUri(xhr, uri, needsSig, isRpc) { if (unloading) return; + var extraData = null; + + if (isRpc && uri.length > 2000) { + extraData = uri.substring(2000); + uri = uri.substring(0, 2000); + } + xhr.open("POST", uri, true); xhr.setRequestHeader("Content-type", "text/plain"); try { @@ -1161,7 +1168,7 @@ } inFlight = cons(xhr, inFlight); - xhr.send(null); + xhr.send(extraData); } function xhrFinished(xhr) { @@ -1211,7 +1218,7 @@ } }; - requestUri(xhr, uri, needsSig); + requestUri(xhr, uri, needsSig, true); } function path_join(s1, s2) { @@ -1260,7 +1267,7 @@ var connect = function () { xhr.onreadystatechange = orsc; tid = window.setTimeout(onTimeout, timeout * 500); - requestUri(xhr, uri, false); + requestUri(xhr, uri, false, false); } orsc = function() {
--- a/src/cjr_print.sml Sat Mar 03 16:20:54 2012 -0500 +++ b/src/cjr_print.sml Sat Mar 03 16:41:20 2012 -0500 @@ -2971,6 +2971,18 @@ newline, string "if (*request == '/') ++request;", newline, + case ek of + Rpc _ => box [string "if (uw_hasPostBody(ctx)) {", + newline, + box [string "uw_Basis_postBody pb = uw_getPostBody(ctx);", + newline, + string "if (pb.data[0])", + newline, + box [string "request = uw_Basis_strcat(ctx, request, pb.data);"], + newline], + string "}", + newline] + | _ => box [], if couldWrite ek andalso not (Settings.checkNoXsrfProtection s) then box [string "{", newline,