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

multipart POST broke in v2.48.0 #1274

Closed
bradvogel opened this issue Nov 18, 2014 · 3 comments · Fixed by #1275
Closed

multipart POST broke in v2.48.0 #1274

bradvogel opened this issue Nov 18, 2014 · 3 comments · Fixed by #1275

Comments

@bradvogel
Copy link

Hi, I just upgraded to v2.48.0 and my request to the Google API broke. Compare the following:

In 2.47.0, the following request returns the expected response ("Unauthorized"):

$ npm install request@2.47.0
$ node
> require('request')({
...       method: 'POST',
...       url: 'https://www.googleapis.com/batch',
...       multipart: [{
.....         'Content-Type': 'application/http',
.....         'body': 'GET https://www.googleapis.com/gmail/v1/users/me/messages/asdf\n'
.....       }],
...       headers: {
.....         'content-type': 'multipart/mixed'
.....       }
...     }, function(err, response) {
...       console.log(err, response.body);
...     });
> null '--batch_ODl35evuJ0c_AAJlyu9-hb4\r\nContent-Type: application/http\r\n\r\nHTTP/1.1 401 Unauthorized\r\nWWW-Authenticate: Bearer realm="https://accounts.google.com/AuthSubRequest"\r\nContent-Type: application/json; charset=UTF-8\r\nDate: Tue, 18 Nov 2014 07:44:24 GMT\r\nExpires: Tue, 18 Nov 2014 07:44:24 GMT\r\nCache-Control: private, max-age=0\r\nContent-Length: 238\r\n\r\n{\n "error": {\n  "errors": [\n   {\n    "domain": "global",\n    "reason": "required",\n    "message": "Login Required",\n    "locationType": "header",\n    "location": "Authorization"\n   }\n  ],\n  "code": 401,\n  "message": "Login Required"\n }\n}\n\r\n--batch_ODl35evuJ0c_AAJlyu9-hb4--\r\n'

The same request in v2.48.0 returns "Invalid value" from the Google API:

$ npm install request@2.48.0
$ node
> require('request')({
...       method: 'POST',
...       url: 'https://www.googleapis.com/batch',
...       multipart: [{
.....         'Content-Type': 'application/http',
.....         'body': 'GET https://www.googleapis.com/gmail/v1/users/me/messages/asdf\n'
.....       }],
...       headers: {
.....         'content-type': 'multipart/mixed'
.....       }
...     }, function(err, response) {
...       console.log(err, response.body);
...     });
> null 'Invalid value for header Content-Type: multipart/related; boundary=910e28a4-1de0-4562-aa4e-7fd88d09d10f'

I tried using the new chunked setting to no avail:

multipart: {
        chunked: false,
        data: [{
          'Content-Type': 'application/http',
          'body': 'GET https://www.googleapis.com/gmail/v1/users/me/messages/asdf\n'
        }]
      },
@simov
Copy link
Member

simov commented Nov 18, 2014

@bradvogel I just pushed a fix 👍

In the meantime you can use request v2.47 as this bug was introduced in v2.48

@bradvogel
Copy link
Author

Cool thanks, when will 2.49.0 be out?

@simov
Copy link
Member

simov commented Nov 18, 2014

I guess in a couple of days at most.

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

Successfully merging a pull request may close this issue.

2 participants