Skip to content

Commit

Permalink
Merge pull request #2323 from Shopify/all-the-headers
Browse files Browse the repository at this point in the history
Add additional headers and standardize X-prefixed ones
  • Loading branch information
atesgoral committed Jun 21, 2022
2 parents 2b11275 + 44eb347 commit aee8bdd
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .changeset/beige-kangaroos-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@shopify/network': minor
'@shopify/graphql-testing': patch
'@shopify/react-graphql': patch
---

Add additional headers and standardize X-prefixed ones
69 changes: 53 additions & 16 deletions packages/network/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,11 @@ export enum StatusCode {
HttpVersionNotSupported = 505,
}

// Keep this sorted
export enum Header {
Accept = 'Accept',
ContentType = 'Content-Type',
ContentDisposition = 'Content-Disposition',
UserAgent = 'User-Agent',
XhrRedirectedTo = 'X-XHR-Redirected-To',
XhrReferer = 'X-XHR-Referer',
ContentSecurityPolicy = 'Content-Security-Policy',
ContentSecurityPolicyReportOnly = 'Content-Security-Policy-Report-Only',
Forwarded = 'Forwarded',
ForwardedFor = 'X-Forwarded-For',
ForwardedHost = 'X-Forwarded-Host',
ForwardedProtocol = 'X-Forwarded-Proto',
AcceptEncoding = 'Accept-Encoding',
AcceptLanguage = 'Accept-Language',
AccessControlAllowCredentials = 'Access-Control-Allow-Credentials',
AccessControlAllowHeaders = 'Access-Control-Allow-Headers',
AccessControlAllowMethods = 'Access-Control-Allow-Methods',
Expand All @@ -76,14 +68,59 @@ export enum Header {
AccessControlMaxAge = 'Access-Control-Max-Age',
AccessControlRequestHeaders = 'Access-Control-Request-Headers',
AccessControlRequestMethod = 'Access-Control-Request-Method',
Authorization = 'Authorization',
CacheControl = 'Cache-Control',
AcceptLanguage = 'Accept-Language',
XssProtecton = 'X-XSS-Protection',
FrameOptions = 'X-Frame-Options',
DownloadOptions = 'X-Download-Options',
CacheStatus = 'Cache-Status',
Connection = 'Connection',
ContentDisposition = 'Content-Disposition',
ContentEncoding = 'Content-Encoding',
ContentLength = 'Content-Length',
ContentSecurityPolicy = 'Content-Security-Policy',
ContentSecurityPolicyReportOnly = 'Content-Security-Policy-Report-Only',
ContentType = 'Content-Type',
/** @deprecated Use XContentTypeOptions instead. */
ContentTypeOptions = 'X-Content-Type-Options',
StrictTransportSecurity = 'Strict-Transport-Security',
Cookie = 'Cookie',
/** @deprecated Use XDownloadOptions instead. */
DownloadOptions = 'X-Download-Options',
ETag = 'ETag',
Forwarded = 'Forwarded',
/** @deprecated Use XForwardedFor instead. */
ForwardedFor = 'X-Forwarded-For',
/** @deprecated Use XForwardedHost instead. */
ForwardedHost = 'X-Forwarded-Host',
/** @deprecated Use XForwardedProto instead. */
ForwardedProtocol = 'X-Forwarded-Proto',
/** @deprecated Use XFrameOptions instead. */
FrameOptions = 'X-Frame-Options',
Host = 'Host',
IfNoneMatch = 'If-None-Match',
Location = 'Location',
Origin = 'Origin',
ReferrerPolicy = 'Referrer-Policy',
ServerTiming = 'Server-Timing',
StrictTransportSecurity = 'Strict-Transport-Security',
TimingAllowOrigin = 'Timing-Allow-Origin',
Trailer = 'Trailer',
TransferEncoding = 'Transfer-Encoding',
UserAgent = 'User-Agent',
WwwAuthenticate = 'WWW-Authenticate',
/** @deprecated Use XXhrRedirectedTo instead. */
XhrRedirectedTo = 'X-XHR-Redirected-To',
/** @deprecated Use XXhrReferer instead. */
XhrReferer = 'X-XHR-Referer',
/** @deprecated Use XXssProtecton instead. */
XssProtecton = 'X-XSS-Protection',
// X- headers
XContentTypeOptions = 'X-Content-Type-Options',
XDownloadOptions = 'X-Download-Options',
XForwardedFor = 'X-Forwarded-For',
XForwardedHost = 'X-Forwarded-Host',
XForwardedProto = 'X-Forwarded-Proto',
XFrameOptions = 'X-Frame-Options',
XXhrRedirectedTo = 'X-XHR-Redirected-To',
XXhrReferer = 'X-XHR-Referer',
XXssProtecton = 'X-XSS-Protection',
}

export enum CspDirective {
Expand Down

0 comments on commit aee8bdd

Please sign in to comment.