Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.32k stars 445 forks source link

Force HTTP headers to be case insensitive #1236

Closed jeremyfiel closed 6 months ago

jeremyfiel commented 10 months ago

You can easily achieve this by adding a custom http header in your request headers X-Request-Type: GraphQL, or simply type graphql, a built-in snippet will be available for you. Here I use the example provided by @ferronrsmith himself


POST http://localhost:60000/graphql HTTP/1.1
content-type: application/json
x-request-type: GraphQL
Authorization: Bearer xxxx

query ($context: ListDataFilesInput) { listDataFiles(input: $context) { name, lastModified } }

{ "context": { "customerCode": "test", "meshKey": "test", "dataBucketCode": "test-bucket", "filter": "" } }



_Originally posted by @Huachao in https://github.com/Huachao/vscode-restclient/issues/127#issuecomment-509490845_

@Huachao @ferronrsmith

can you force all headers to be lowercase as per HTTP RFC2616 Section 4.2.

https://datatracker.ietf.org/doc/html/rfc2616#section-4.2

I was really struggling with using the graphql functionality until I figured out the code snippet above is looking for case sensitive string `x-request-type: GraphQL`

 thanks so much for your contribution.