-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
How can I specify headers for one request? #284
How can I specify headers for one request? #284
Comments
Hmm, I'm curious why you need to do this? You can specify additional settings when you initialize the googleapis object that are 1:1 mapping of mikeal/request options but those will get applied to every request. Example (apply var google = require('googleapis');
google.options({ headers: { 'Content-Type': 'application/json' } }); You shouldn't need to do this though so I'm curious why (maybe we can fill some developer need here)? |
There isn't really a nice way to apply headers to a single request right now. If you can make a good case for it, this might help push along such a feature. |
I want to set Etag header, which is diferrent for every request (for different resource). I fixed this in my fork: https://github.com/JakubMrozek/google-api-nodejs-client/blob/master/lib/apirequest.js#L150 I can send a pull request if you want... |
This will work for most cases unless an api endpoint uses 'headers' as a property name for some parameter. I find that event unlikely to happen, but this is reason why we try to limit the number of additional properties on the top level object specified in a request. @rakyll perhaps you can chime in here about a reasonable trade-off for specifying additional options per-request? |
What API are using the ETag header with? In the Drive API for example, you can specify the ETag of a files resource by using params.etag See https://developers.google.com/drive/v2/reference/files#resource Does the API you're using support a similar value? If not, I can consider merging your params.headers diff if you send a PR. Seems no API uses params.headers as a property name so we should be pretty safe to use it. |
@JakubMrozek does the |
It is possible? I need different headers for every requests. In the previos version, there was a simple method setHeaders(), but I don't know how to specify header options only for one request now.
The text was updated successfully, but these errors were encountered: