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

Endpoint properly handles Accept header #36

Merged
merged 2 commits into from
Feb 16, 2018

Conversation

roycaihw
Copy link
Member

@roycaihw roycaihw commented Feb 7, 2018

Sort Accept header with q parameter

NOTE: I manually changed Godep.json. goautoneg is used in kubernetes already.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 7, 2018
@roycaihw
Copy link
Member Author

roycaihw commented Feb 9, 2018

cc @liggitt

return
for _, clause := range clauses {
for _, accepts := range accepted {
if clause.Type == accepts.Type && clause.SubType == accepts.SubType ||
Copy link
Member

@liggitt liggitt Feb 10, 2018

Choose a reason for hiding this comment

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

nit, might be more readable unnested like this:

if clause.Type != accepts.Type && clause.Type != "*" {
  continue
}
if clause.SubType != accepts.SubType && clause.SubType != "*" {
  continue
}

data, etag, lastModified := accepts.GetDataAndETag()
w.Header().Set("Etag", etag)
// ServeContent will take care of caching using eTag.
http.ServeContent(w, r, servePath, lastModified, bytes.NewReader(data))
return

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@liggitt
Copy link
Member

liggitt commented Feb 10, 2018

just noticed there are no tests in this package... probably worthwhile to test here before doing a vendor cycle into kube

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 15, 2018
use goautoneg.ParseAccept to sort Accept header
@roycaihw
Copy link
Member Author

@liggitt I've added the test for Accept header's behavior. Please take a look :)

@roycaihw
Copy link
Member Author

@mbohlool @liggitt Could we merge this one before the code slush, to avoid changing the deprecation schedule?

@liggitt
Copy link
Member

liggitt commented Feb 16, 2018

code change LGTM
it's a little concerning that vendoring has to be updated manually in this repo

@mbohlool
Copy link
Contributor

@liggitt I agree, we need to port some of the main repo tools to this repo or develop a set of generic tool from them for any repo like this.

@mbohlool
Copy link
Contributor

this code looks good to me too.

@mbohlool mbohlool merged commit c93118b into kubernetes:master Feb 16, 2018
sttts pushed a commit to sttts/kube-openapi that referenced this pull request Nov 5, 2020
sttts pushed a commit to sttts/kube-openapi that referenced this pull request Nov 5, 2020
Fixes kubernetes#36 Hostname matching doesn't conform to modern hostname patterns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants