rendrjs / rendr-app-template

Basic skeleton for a Rendr app. Deprecated in favor of ./examples dir in rendr repo.
MIT License
285 stars 83 forks source link

apiProxy should handle status code 204 properly #44

Closed koichik closed 11 years ago

koichik commented 11 years ago

An API server may return "204 No Content" for PUT or DELETE request, but apiProxy ignores it and returns "200 OK" on the server side.

      // Pass through statusCode, but not if it's an i.e. 304.
      status = response.statusCode;
      if (utils.isErrorStatus(status)) {
        res.status(status);
      }
      res.json(body);

Then, on the client side, jQuery detects "parseerror" because the response has no body. Actually, this error occurs from "304 Not Modified" too. So, I'm not sure of this comment, but workaround is here.

      // Pass through statusCode, but not if it's an i.e. 304.
      status = response.statusCode;
      if (utils.isErrorStatus(status) || +status === 204) {

However, I believe apiProxy always should pass through status code and also end-to-end headers.

koichik commented 11 years ago

Oops, this repo is not rendr's. Sorry, closing.