Skip to content
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

Closed
spikhoff opened this issue Feb 26, 2014 · 5 comments
Closed

json client, wrong content-type on delete method #539

spikhoff opened this issue Feb 26, 2014 · 5 comments

Comments

@spikhoff
Copy link

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

@VaclavObornik
Copy link

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...

@micahr micahr added this to the Release: 3.1.x milestone Jun 17, 2015
@micahr
Copy link
Member

micahr commented Jun 17, 2015

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.

@retrohacker retrohacker removed this from the Release: 3.1.x milestone Apr 29, 2017
@retrohacker
Copy link
Member

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);
  });
});

@hekike
Copy link
Member

hekike commented Apr 3, 2018

Moved to:
restify/clients#163

@hekike hekike closed this as completed Apr 3, 2018
@einarjohnson
Copy link

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.

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

No branches or pull requests

7 participants