Closed taemon1337 closed 7 years ago
The request fails
Can you clarify what you mean with this? I've tried to reproduce locally with the following code (modifying the URL and the test.txt
path):
var Promise = require("bluebird");
var bhttp = require("bhttp");
var fs = require("fs");
Promise.try(function() {
return bhttp.post("http://localhost:5000/upload", { tags: ['one','two','three'], file: fs.createReadStream('./test.txt') }, { forceMultipart: true });
}).then(function(resp) {
console.log("Response: ", err);
}).catch(function(err) {
console.log("Error: ", err);
});
... and the request is sent successfully and correctly:
POST /upload HTTP/1.1
user-agent: bhttp/1.2.4
content-length: 570
content-type: multipart/form-data; boundary=----1534fc32-7532-49cb-9c9e-a5af8595d7d6
Host: localhost:5000
Connection: close
------1534fc32-7532-49cb-9c9e-a5af8595d7d6
Content-Disposition: form-data; name="tags[]"
Content-Type: text/plain
one
------1534fc32-7532-49cb-9c9e-a5af8595d7d6
Content-Disposition: form-data; name="tags[]"
Content-Type: text/plain
two
------1534fc32-7532-49cb-9c9e-a5af8595d7d6
Content-Disposition: form-data; name="tags[]"
Content-Type: text/plain
three
------1534fc32-7532-49cb-9c9e-a5af8595d7d6
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
foo
bar
baz
------1534fc32-7532-49cb-9c9e-a5af8595d7d6--
Sorry for the trouble, I was able to work around the issue I had (which must have been with the server side code); the request was timing out from either the client or server. Either way, I've gotten mine working now and lost the code which doesn't work, so thanks anyway.
The request fails without any console log message.