Post multipart bug in NetHttpd ?
Pierre-Alexandre Voye <[email protected]> Thu, 29 Dec 2011 11:09:42 +0100
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <CANnJ5GfyjVC=eCTtEeSL2NcBgvMSJ30rnC5bMEhSRQqnMSxOAg@mail.gmail.com> |
Hello, i'm writing code to manage upload from a browser. Even if I use a XmlHttpRequest, i cannot fully control the http request to the server When i try to validate it with curl i have a strange error. Here's the curl command line (which use attached file): curl -F "[email protected];filename=404.html" http://localhost:8111/upload--trace-ascii - I suppose Curl respect the standard. But it's certainly my code which is not wrote like it should. Here's my CGI (I know I have to use NetMime, but I don't understand enought NetMime to use it) : let defini_CGI_Upload (cgi : Netcgi.cgi_activation) = try let out = cgi # output # output_string in let server_file arg = match arg#store with | `File fn -> fn | `Memory -> failwith "Not stored in a file" in match cgi#request_method with | `POST -> traite_upload { nom_fichier = cgi#argument_value "filename" ; contentType = cgi#argument_value "contentType" ; content = cgi#argument_value "content"; filenametmp = server_file (cgi#argument (cgi#argument_value "filename") ) } ; (*cgi#finalize();*) | _ -> cgi#output#output_string "Server accepts POST requests only.\n"; cgi # set_header ~cache:`No_cache ~content_type:"text/html; charset=\"iso-8859-1\"" (); cgi # output # commit_work();raise Erreur_durant_L_upload_Post with error -> cgi # output # rollback_work(); cgi # set_header ~status:`Forbidden ~cache:`No_cache ~content_type:"text/html; charset=\"utf-8\"" (); cgi # output # output_string "While processing the request an O'Caml exception has been raised:<BR>"; cgi # output # output_string ("<TT>" ^ (Printexc.to_string error)^ (Printexc.get_backtrace ()) ^ "</TT><BR>"); (* Now commit the error page: *) cgi # output # commit_work() ; raise Erreur_durant_L_upload ;; Here the backtrace I have : Not_found Raised by primitive operation at file "map.ml", line 118, characters 16-25. Called from file "netmime.ml", line 326, characters 14-31. So it's in update_multiple_field method For information, here's the transcript of curl session : $ curl -F "[email protected];filename=404.html" http://localhost:8111/upload--trace-ascii - == Info: About to connect() to localhost port 8111 (#0) == Info: Trying ::1... == Info: Connection refused == Info: Trying 127.0.0.1... == Info: connected => Send header, 296 bytes (0x128) 0000: POST /upload HTTP/1.1 0017: User-Agent: curl/7.23.1 (x86_64-apple-darwin11.2.0) libcurl/7.23 0057: .1 OpenSSL/1.0.0e zlib/1.2.5 libidn/1.22 0081: Host: localhost:8111 0097: Accept: */* 00a4: Content-Length: 1541 00ba: Expect: 100-continue 00d0: Content-Type: multipart/form-data; boundary=-------------------- 0110: --------402388b44fe6 0126: <= Recv header, 23 bytes (0x17) 0000: HTTP/1.1 100 Continue => Send data, 137 bytes (0x89) 0000: ------------------------------402388b44fe6 002c: Content-Disposition: form-data; name="file"; filename="404.html" 006e: Content-Type: text/html 0087: => Send data, 1356 bytes (0x54c) 0000: <!doctype html>.<html>.<head>. <meta charset="utf-8">. <title> 0040: Page Not Found :(</title>. <style>.. body { text-align: center 0080: ;}.. h1 { font-size: 50px; text-align: center }.. span[frown] 00c0: { transform: rotate(90deg); display:inline-block; color: #bbb; } 0100: .. body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon 0140: Pro", Baskerville, Georgia, Times, serif; color: #999; text-sha 0180: dow: 2px 2px 2px rgba(200, 200, 200, 0.5); }.. ::-moz-selection 01c0: { background:#FF5E99; color:#fff; }.. ::selection { background: 0200: #FF5E99; color:#fff; } .. article {display:block; text-align: l 0240: eft; width: 500px; margin: 0 auto; }.. .. a { color: rgb(36, 1 0280: 09, 56); text-decoration:none; }.. a:hover { color: rgb(96, 73, 02c0: 141) ; text-shadow: 2px 2px 2px rgba(36, 109, 56, 0.5); }. </s 0300: tyle>.</head>.<body>. <article>.. <h1>Not found <span frown 0340: >:(</span></h1>.. <div>.. <p>Sorry, but the page you wer 0380: e trying to view does not exist.</p>.. <p>It looks like th 03c0: is was the result of either:</p>.. <ul>... <li>a mistype 0400: d address</li>... <li>an out-of-date link</li>.. </ul>.. 0440: </div>.. .. <script>.. var GOOG_FIXURL_LANG = (navig 0480: ator.language || '').slice(0,2),...GOOG_FIXURL_SITE = location.h 04c0: ost;.. </script>.. <script src="http://linkhelp.clients.go 0500: ogle.com/tbproxy/lh/wm/fixurl.js"></script>. </article>.</bo 0540: dy>.</html>. => Send data, 48 bytes (0x30) 0000: 0002: ------------------------------402388b44fe6-- <= Recv header, 24 bytes (0x18) 0000: HTTP/1.1 403 Forbidden <= Recv header, 42 bytes (0x2a) 0000: Content-Type: text/html; charset="utf-8" <= Recv header, 25 bytes (0x19) 0000: Cache-control: no-cache <= Recv header, 18 bytes (0x12) 0000: Pragma: no-cache <= Recv header, 42 bytes (0x2a) 0000: Expires: Thu, 29 Dec 2011 09:49:25 +0000 <= Recv header, 28 bytes (0x1c) 0000: Transfer-Encoding: chunked <= Recv header, 37 bytes (0x25) 0000: Date: Thu, 29 Dec 2011 09:49:26 GMT <= Recv header, 24 bytes (0x18) 0000: Server: Ocamlnet/3.4.1 == Info: HTTP error before end of send, stop sending <= Recv header, 2 bytes (0x2) 0000: <= Recv data, 228 bytes (0xe4) 0000: e0 0004: While processing the request an O'Caml exception has been raised 0044: :<BR><TT>Not_foundRaised by primitive operation at file "map.ml" 0084: , line 118, characters 16-25.Called from file "netmime.ml", line 00c4: 326, characters 14-31.</TT><BR> While processing the request an O'Caml exception has been raised:<BR><TT>Not_foundRaised by primitive operation at file "map.ml", line 118, characters 16-25 Called from file "netmime.ml", line 326, characters 14-31 </TT><BR><= Recv data, 2 bytes (0x2) 0000: == Info: transfer closed with outstanding read data remaining == Info: Closing connection #0 curl: (18) transfer closed with outstanding read data remaining Thank you -- --------------------- https://twitter.com/#!/ontologiae/ http://linuxfr.org/users/montaigne ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Ocamlnet-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel
404.html
(text/html, 1.3 KB)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Page Not Found :(</title>
<style>
body { text-align: center;}
h1 { font-size: 50px; text-align: center }
span[frown] { transform: rotate(90deg); display:inline-block; color: #bbb; }
body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon Pro", Baskerville, Georgia, Times, serif; color: #999; text-shadow: 2px 2px 2px rgba(200, 200, 200, 0.5); }
::-moz-selection{ background:#FF5E99; color:#fff; }
::selection { background:#FF5E99; color:#fff; }
article {display:block; text-align: left; width: 500px; margin: 0 auto; }
a { color: rgb(36, 109, 56); text-decoration:none; }
a:hover { color: rgb(96, 73, 141) ; text-shadow: 2px 2px 2px rgba(36, 109, 56, 0.5); }
</style>
</head>
<body>
<article>
<h1>Not found <span frown>:(</span></h1>
<div>
<p>Sorry, but the page you were trying to view does not exist.</p>
<p>It looks like this was the result of either:</p>
<ul>
<li>a mistyped address</li>
<li>an out-of-date link</li>
</ul>
</div>
<script>
var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),
GOOG_FIXURL_SITE = location.host;
</script>
<script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
</article>
</body>
</html>