We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heres some example code...
var express = require('express'); var bodyParser = require('body-parser'); var bhttp = require('bhttp'); var app = express(); //app.use(bodyParser.json()); app.use(bodyParser.text()); app.post('/', function (req, res) { console.log("Server::headers: ",req.headers); console.log("Server::body: ",req.body); console.log("Server::params: ",req.params); res.sendStatus(200); }); var server = app.listen(3000, function(){ var opts = { url: "http://localhost:3000/", data: 'test' }; bhttp.post(opts.url, opts.data) .then(function(res){ console.log("Client::statusCode: ", res.statusCode); return bhttp.post(opts.url, opts.data, {headers: {"content-type":"text/plain"}}); }) .then(function(res){ console.log("Client::statusCode: ", res.statusCode); process.exit(); }); });
And the output...
Server::headers: { 'user-agent': 'bhttp/1.2.1', 'content-length': '4', host: 'localhost:3000', connection: 'close' } Server::body: {} Client::statusCode: 200 Server::headers: { 'content-type': 'text/plain', 'user-agent': 'bhttp/1.2.1', 'content-length': '4', host: 'localhost:3000', connection: 'close' } Server::body: test Client::statusCode: 200
There isn't any content-type passed in the first post. Only when manually defining the content type can the text/plain type be set.
Thanks!
The text was updated successfully, but these errors were encountered:
To do:
text/plain
Sorry, something went wrong.
joepie91
No branches or pull requests
Heres some example code...
And the output...
There isn't any content-type passed in the first post. Only when manually defining the content type can the text/plain type be set.
Thanks!
The text was updated successfully, but these errors were encountered: