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

Add a "headers" option to IRequestOptions #436

Closed
wants to merge 3 commits into from

Conversation

rgwozdz
Copy link
Contributor

@rgwozdz rgwozdz commented Jan 16, 2019

This PR does the following

  1. adds a headers option to IRequestOptions. Optional headers are passed on to the target request.

  2. in Node environments, the presence of the headers options prevents the default referer header
    "@esri/arcgis-rest" from being set on the request. If a referer is desired, it can be set with the header option.

I have found that (2) is critical in a particular case; ArcGIS search service sometimes rejects a request with a valid token when the referer is set to "@esri/arcgis-rest". (Note that in such cases, ArcGIS search returns a 498 Invalid token response; but stripping the referer header from the request results in a success response, which indicates the problem is not with the token.)

…ass on the headers to the reque

add a "headers" option to IRequestOptions. Optional headers are passed on to the request. When
headers option is present in Node environments, it prevents the default referer header
"@esri/arcgis-rest" from being set on the request.

AFFECTS PACKAGES:
@esri/arcgis-rest-request
if (typeof window === "undefined") {
if (
typeof window === "undefined" &&
requestOptions.headers === undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we set the referrer when headers are passed-in but referer is still undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, that's prob a good call

Copy link
Member

@mjuniper mjuniper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks, Rich!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 99.528% when pulling 266b85a on f/request-options-headers into 435a640 on master.

Copy link
Contributor

@jgravois jgravois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've proposed a few small tweaks in #437

@rgwozdz
Copy link
Contributor Author

rgwozdz commented Jan 16, 2019

Closing this, now covered in #437

@rgwozdz rgwozdz closed this Jan 16, 2019
jgravois pushed a commit that referenced this pull request Jan 16, 2019
@jgravois
Copy link
Contributor

thanks for this contribution @rgwozdz 🌮:tada:!

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 this pull request may close these issues.

5 participants