Skip to content

Instantly share code, notes, and snippets.

@oetiker

oetiker/status Secret

Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oetiker/21107f3b2ceaa6790ecf to your computer and use it in GitHub Desktop.
Save oetiker/21107f3b2ceaa6790ecf to your computer and use it in GitHub Desktop.
content length test
<!DOCTYPE html>
<html>
<head><title>Upload Status</title></head>
<body>
<h1>Upload Analysis</h1>
Content-Length: 200<br/>
Body Length: 198
<pre>------WebKitFormBoundaryws59zNAFCL2uMvIt
Content-Type: application/octet-stream
Content-Disposition: form-data; name=&quot;example&quot;; filename=&quot;one-byte&quot;
------WebKitFormBoundaryws59zNAFCL2uMvIt--</pre>
</body>
</html>
use Mojolicious::Lite;
get '/' => 'form';
post '/upload' => 'status';
app->start;
__DATA__
@@ status.html.ep
<!DOCTYPE html>
<html>
<head><title>Upload Status</title></head>
<body>
<h1>Upload Analysis</h1>
Content-Length: <%= $self->req->headers->content_length %><br/>
Body Length: <%= length($self->req->build_body) %>
<pre><%= $self->req->build_body %></pre>
</body>
</html>
@@ form.html.ep
<!DOCTYPE html>
<html>
<head><title>Upload</title></head>
<body>
%= form_for upload => (enctype => 'multipart/form-data') => (method => 'POST') => begin
%= file_field 'example'
%= submit_button 'Upload'
% end
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment