Commit Graph

27 Commits

Author SHA1 Message Date
Markus Wolf 3ef26a0052 Align with es6 modules
This adds a default export so it could be used
with es6 modules default export as well without
breaking api.
2016-03-12 09:48:00 +01:00
David Frank 6be7c964f8 Merge pull request #58 from item4/master
Add content-length header with form-data
2016-03-09 23:54:23 +08:00
Kirill Konshin e658483ebe Fix for #38 and #36
Support string/buffer bodies in Response constructor
Request should have Body methods like text(), json()
2016-02-17 10:50:55 -08:00
Kim Jin Su d60e9acbca Add content-length header with form-data
Old source do not add content-length header automatically
with form-data. If body is instance of form-data, Users
must missing this header. It cause parse error with some
server engine like WSGI. WSGI must drop body if this was not
set, and WSGI based frameworks such as flask can not read
form data.

For example, this python code with flask..

----
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/', method=['POST'])
def index():
    return jsonify(**request.form)

app.run()
----

Can not receive any data from this code.

----
require('es6-promise').polyfill();
var fetch = require('isomorphic-fetch'); // it use node-fetch
var FormData = require('form-data');

var data = new FormData();
data.append('name', 'item4');
data.append('message', 'it is test!');
fetch('http://localhost:5000', {method: 'POST', body: data})
  .then(function (data) {
    return data.json();
  })
  .then(function (data) {
    console.log(data);
  });
----

This commit just use FormData's getLengthSync method.
2015-11-26 06:54:51 +09:00
David Frank b48757013a per spec, follow redirect with GET request 2015-09-28 22:30:41 +08:00
David Frank a3e14b503a make sure we support latest node and legacy node 2015-09-28 20:46:39 +08:00
David Frank cfe98cdd35 make sure we don't overwrite existing content-length 2015-09-28 19:27:57 +08:00
David Frank c22bfa8189 auto add content-length on for string body 2015-09-28 17:40:58 +08:00
David Frank 565ec4b35a additional tests for the new form-data integration 2015-07-22 15:40:52 +08:00
Dylan Piercey ffac4177b0 Automatically pull headers from node-form-data. 2015-07-22 02:05:06 +00:00
David Frank b64073c64c update comment to explain hack, make use of inpsect route in test, and update changelog 2015-07-11 19:38:26 +08:00
Matthew Andrews 61fad6a76a Add hack to allow the host to be customized 2015-07-11 10:37:51 +01:00
David Frank 9b5330dfe3 add basic test case for request 2015-06-04 12:12:27 +08:00
David Frank 694b2300f9 basic refactor for request 2015-06-04 12:05:01 +08:00
Rhys Evans 5e4d9b1a60 expose response and headers constructors 2015-05-03 09:43:59 +01:00
David Frank e09dfae0a5 timeout on body and clear timeout internally 2015-04-17 13:26:55 +08:00
Kirill Dmitrenko f79bbf5c07 Clear request timeout after response 2015-04-16 19:01:29 +03:00
David Frank a8bb5650ad fix follow=0 scenario 2015-03-20 00:22:23 +08:00
James Campos a47b8077b2 timeout tweak 2015-02-01 04:36:17 -08:00
David Frank ff81206c4a better test coverage 2015-01-28 01:00:53 +08:00
David Frank 53a763beab more tests 2015-01-27 23:33:06 +08:00
David Frank af21ae6c1c basic refactor done 2015-01-27 21:11:26 +08:00
David Frank 93a983d815 basic fetch feature done 2015-01-27 01:46:32 +08:00
David Frank f57ebe10df basic streaming body 2015-01-26 21:58:52 +08:00
David Frank 78853fc544 add test cases 2015-01-26 21:28:23 +08:00
David Frank 75699bb467 basic http added 2015-01-26 18:15:07 +08:00
David Frank 9c472a52f2 setup repo 2015-01-26 17:02:34 +08:00