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

[Tables] Fix and enable Batch browser tests #13955

Merged
merged 1 commit into from
Mar 4, 2021
Merged

[Tables] Fix and enable Batch browser tests #13955

merged 1 commit into from
Mar 4, 2021

Conversation

joheredi
Copy link
Member

Fixes #11603

Accept-Charset and Connection headers are marked as unsafe in some browsers. Fixing this issue by only adding them if running in Node

@ghost ghost added the Tables label Feb 24, 2021
@@ -9,117 +9,113 @@ import { isNode } from "../testUtils";
import { Uuid } from "../../src/utils/uuid";
import * as sinon from "sinon";

if (isNode || isLiveMode()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only line removed in this file. The rest is formatting from the prettier commit hook

@joheredi joheredi requested review from ellismg and xirzec February 24, 2021 05:12
Copy link
Member

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

LGTM!

const baseHeaders = getBaseBatchHeaders(batchGuid);
return {
...baseHeaders,
// The below headers are not supported in the browser as they are flagged as "unsafe headers"
Copy link
Member

Choose a reason for hiding this comment

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

@jeremymeng
Copy link
Member

Should we remove unsafe headers for browsers in core? The fetch spec indicates that they would not be added to requests. @bterlson @xirzec

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

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

I love this fix!

Left a small suggestion about how the implementation could be tweaked.

* @internal
* Builds an object with the required headers for a Batch request. For the Browser
*/
export const getBatchHeaders = getBaseBatchHeaders;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be easier to write a function that filters out "unsafe" headers and apply that here, rather than relying on folks knowing to only add them to the node version?

@xirzec
Copy link
Member

xirzec commented Feb 25, 2021

Should we remove unsafe headers for browsers in core? The fetch spec indicates that they would not be added to requests. @bterlson @xirzec

What happens if someone tries to set them on xhr/fetch? Does it make the request fail? If so, I think adding a header filter to XhrHttpsClient is reasonable.

@jeremymeng
Copy link
Member

What happens if someone tries to set them on xhr/fetch? Does it make the request fail? If so, I think adding a header filter to XhrHttpsClient is reasonable.

Reading more specs, it looks that adding/setting/deleting/ forbidden headers should be a no-op. So it's the FakeXMLHttpRequest from nise that doesn't follow the spec. I will log an issue there to see whether it is a bug or by-design.

@joheredi joheredi merged commit 10e4017 into Azure:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tables] Batch integration test fail when run in playback mode against browser
4 participants