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

Instead of using http.CanonicalHeaderKey to check if a header exists,, you can directly use the response.Header.Get(header) method. #62

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Montana
Copy link

@Montana Montana commented May 30, 2024

Hello @nytimes!

Instead of using http.CanonicalHeaderKey to check if a header exists, you can directly use the response.Header.Get(header) method.

So instead of using validateResponseHeaderPatterns function, instead of using http.CanonicalHeaderKey to check if a header exists, you can directly use the response.Header.Get(header) method. It automatically handles case-insensitive header names.

Use a switch statement instead of multiple if conditions for validating the HTTP method in the preProcessTest function. It will be more concise and easier to read.

Extract the header validation logic from validateResponseHeaders into separate functions for each type of assertion (patterns, notMatching, notPresent, ifPresentNotMatching).

This will make the code more modular and easier to understand. I've written these "updates" into this.

Cheers,
Michael Mendy

…s,, you can directly use the `response.Header.Get(header)` method.

So instead of using `validateResponseHeaderPatterns` function, instead of using `http.CanonicalHeaderKey` to check if a header exists, you can directly use the `response.Header.Get(header)` method. It automatically handles case-insensitive header names.

Use a switch statement instead of multiple if conditions for validating the HTTP method in the `preProcessTest` function. It will be more concise and easier to read.

Extract the header validation logic from validateResponseHeaders into separate functions for each type of assertion (patterns, `notMatching`, `notPresent`, `ifPresentNotMatching`). 

This will make the code more modular and easier to understand.
@Montana Montana requested a review from a team as a code owner May 30, 2024 17:38
@Montana Montana requested review from adamdabbracci, mikeshort10 and edonasaliu and removed request for a team May 30, 2024 17:38
@xawpaw
Copy link

xawpaw commented May 30, 2024

Really good call on using the switch statement.

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.

4 participants