Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Work around issue with GET requests with json content type and invali…

…d body

Related to senchalabs/connect#680
  • Loading branch information...
commit c19ec848c0421f27f9aac54c2d1b91ac2bde58f7 1 parent ca40625
Edmund von der Burg evdb authored
Showing with 24 additions and 0 deletions.
  1. +9 −0 server.js
  2. +15 −0 tests/api/basics.js
9 server.js
View
@@ -15,6 +15,15 @@ var express = require('express'),
var app = express();
+// Intercept JSON content type GET requests and change the header.
+// this is a workaround for https://github.com/senchalabs/connect/issues/680 which hopefully will be fixed upstream
+app.use( function (req, res, next) {
+ if ( req.method == "GET" && req.headers['content-type'] == 'application/json' ) {
+ delete req.headers['content-type'];
+ }
+ next();
+});
+
// match the hosting app host...
app.use(
express.vhost(
15 tests/api/basics.js
View
@@ -31,6 +31,21 @@ module.exports = {
test_server_helpers.stop_server(tearDown_done);
},
+ "GET with content-type of json and no body": function (test) {
+ // this is a workaround for https://github.com/senchalabs/connect/issues/680 which hopefully will be fixed upstream
+ test.expect(1);
+ this.rest
+ .get('',{
+ headers: {'Content-Type': 'application/json'}, // set json...
+ data: '', // ... but include no data
+ })
+ .on('complete', function(data, response) {
+ test.equal(response.statusCode, 200, "got 200 response");
+ test.done();
+ });
+
+ },
+
"access API docs": function (test) {
test.expect(2);
Please sign in to comment.
Something went wrong with that request. Please try again.