Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

multipart working or broke? #394

danielb2 opened this Issue Dec 26, 2012 · 3 comments


None yet
2 participants

Either I'm doing this wrong or things are broken. I'm using this as best as I can from reading the docs.

This is my code:

     r = request                                                      
       uri: 'http://localhost:4567'                                   
       headers: {'User-Agent': 'Something. Because its bad if its null in my use-case'}      
       method: 'POST'                                                 
     , (err,res, body) ->                                             
       console.log body                                               
       console.log err                                                
     form = r.form()                                                  
     form.append 'my_field', 'my_value'                               

on port 4567 I have a ruby sinatra process listening in order to print out the data:

#!/usr/bin/env ruby
require 'sinatra'

all = proc do
post '*', &all
get '*', &all

Sinatra fails at this point: negative length -54 given

I try setting Content-Length to something in the headers (even though the documentation says the form lib will deal with this form me) and I get the next error.

IS request failing to set the Content-Length? Am I doing something wrong?


mikeal commented Dec 27, 2012

i don't know coffeescript, please post code in javascript if you want me to be able to read it.

var form, r;

r = request({
  uri: 'http://localhost:4567',
  headers: {
    'User-Agent': 'Something. Because its bad if its null in my use-case'
  method: 'POST'
}, function(err, res, body) {
  return done();

form = r.form();

form.append('my_field', 'my_value');

mikeal commented Aug 27, 2014

Is this still an issue?

This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.

@mikeal mikeal closed this Aug 27, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment