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

fix: Add content-type media type parsing #678

Merged
merged 4 commits into from
Jul 28, 2022

Conversation

fredcarle
Copy link
Collaborator

Relevant issue(s)

Resolves #677

Description

This PR fixes an issue where some http clients add parameters to the content-type and caused the content-type switch to fail.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

unit test

Specify the platform(s) on which this was tested:

  • MacOS

@fredcarle fredcarle added bug Something isn't working area/api Related to the external API component action/no-benchmark Skips the action that runs the benchmark. labels Jul 26, 2022
@fredcarle fredcarle added this to the DefraDB v0.3 milestone Jul 26, 2022
@fredcarle fredcarle requested a review from a team July 26, 2022 22:49
@fredcarle fredcarle self-assigned this Jul 26, 2022
@codecov
Copy link

codecov bot commented Jul 26, 2022

Codecov Report

Merging #678 (480125e) into develop (8139204) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #678      +/-   ##
===========================================
+ Coverage    57.21%   57.24%   +0.02%     
===========================================
  Files          143      143              
  Lines        16383    16393      +10     
===========================================
+ Hits          9374     9384      +10     
  Misses        6127     6127              
  Partials       882      882              
Impacted Files Coverage Δ
api/http/handlerfuncs.go 90.30% <100.00%> (+0.62%) ⬆️

switch req.Header.Get("Content-Type") {
// extract the media type from the content-type header
contentType, _, err := mime.ParseMediaType(req.Header.Get("Content-Type"))
if err != nil && err.Error() != "mime: no media type" {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: add a comment explaining the err.Error() != "mime: no media type" section if possible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me know what you think of the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, very clear

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@orpheuslummis orpheuslummis left a comment

Choose a reason for hiding this comment

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

LGTM

@fredcarle fredcarle force-pushed the fredcarle/fix/I677-content-type-switch branch from 279740e to 480125e Compare July 28, 2022 20:11
@fredcarle fredcarle merged commit 4ff43c5 into develop Jul 28, 2022
@fredcarle fredcarle deleted the fredcarle/fix/I677-content-type-switch branch July 28, 2022 20:21
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Relevant issue(s)
Resolves sourcenetwork#677

Description
This PR fixes an issue where some http clients add parameters to the content-type and caused the content-type switch to fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/api Related to the external API component bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

content-type switch not working with complex types
3 participants