-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
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
json client, wrong content-type on delete method #539
Comments
I have also this problem, cannot send DELETE method without body :(... If body is not defined, Content-Type is empty -> type is resolved as 'application/octet-stream'... then Unsupported Media Type (415) is response.. I'm using superagent - this is not jsonClient related problem... |
This looks like an issue with the router. Not sure why you would be getting flagged as a "typed" request, as only PUT, POST, and PATCH requests should qualify. Add it to the next minor release milestone. |
Thank you for the clear and concise repro case! Marking this as Help Wanted for now until a contributor frees up and gets a chance to tackle it. ❤️ Including the repro case here to save a click: var restify = require('restify');
// create server
var server = restify.createServer();
// Blocks your chain on reading and parsing the HTTP request body.
// Switches on Content-Type and does the appropriate logic.
// application/json, application/x-www-form-urlencoded and multipart/form-data are currently supported.
server.use(restify.bodyParser({rejectUnknown: true}));
server.del('/endpoint', function (req, res, next) {
return next();
});
// create client
var client = restify.createJsonClient({
version: '*',
url: 'http://0.0.0.0:8080'
});
server.listen(8080, function () {
// And here we get UnsupportedMediaTypeError when bodyParser rejectUnknown is set to true.
// JsonClient sends application/octet-stream instead application/json.
client.del('/endpoint', function(err) {
console.log(err);
});
}); |
Moved to: |
Was this issue ever resolved? I'm seeing the same behaviour in 7.2.1. My client sends in a DELETE request and the bodyparser (with rejectUnknown: true) is throwing it back as a "Unsupported Media Type" error. |
Using latest restify (2.6.1) when json client makes http DELETE request it sets content-type to application/octet-stream instead application/json.
Check out this gist:
https://gist.github.com/spikhoff/9229833
The text was updated successfully, but these errors were encountered: