These are chat archives for MrSwitch/node-oauth-shim

22nd
Dec 2014
Milan Simonovic
@mbsimonovic
Dec 22 2014 21:29
@MrSwitch any idea why req in proxy never fires 'data' and 'end' when hit by XHR post request? I'm trying to post a Linkedin company share and got stuck here. req.on('data', ...) has to pass on post data to _req.write(chunk); but that never happens so _req just times out.
Milan Simonovic
@mbsimonovic
Dec 22 2014 21:56
to eliminate linkedin api as a problem, this curl command successfully shares an update:
curl -H 'Content-Type: application/json' --data '{ "visibility": { "code": "anyone" }, "comment": "sharing with hello.js!"}' 'https://api.linkedin.com/v1/companies/9213065/shares?callback=succ&oauth2_access_token=AQWjg***'
but calling oauthproxy this way fails:
curl -H 'Content-Type: application/json' --data '{ "visibility": { "code": "anyone" }, "comment": "sharing with hello.js!"}' 'http://localhost:3000/oauthproxy?path=https%3A%2F%2Fapi.linkedin.com%2Fv1%2Fcompanies%2F9213065%2Fshares%3Foauth2_access_token%3DAQWjg***&access_token=&then=proxy&method=post'
so req.on('data') is never emitted, and it just times out
any hints?
this test works fine (same curl command):
Milan Simonovic
@mbsimonovic
Dec 22 2014 22:02
var http = require('http');
var https = require('https');

var server = http.createServer(function (request, response) {
    if (request.method == 'POST') {
        var body = '';
        request.on('data', function (data) {
            body += data;
        });
        request.on('end', function () {
            console.log("post data: " + body);
            response.end("received");

        });
    }
});
server.listen(3000);
tested with node v0.10.33 and v0.10.34 (on mac)
Milan Simonovic
@mbsimonovic
Dec 22 2014 22:35
ah, think i found it, app.use(bodyParser.json());