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

Enabled HEAD requests + refactoring #31

Merged
merged 2 commits into from
Nov 22, 2016

Conversation

deberth
Copy link
Contributor

@deberth deberth commented Nov 21, 2016

  • enabled head requests
  • refactored servehttp method from composition handler
  • go format

* refactored servehttp method from composition handler
* go format
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.762% when pulling 53de6cc on bugfix/1463-enabled-head-requests into d4e78f0 on master.

if res.Content.HttpStatusCode() >= 300 && res.Content.HttpStatusCode() <= 308 {
copyHeaders(res.Content.HttpHeader(), w.Header(), ForwardResponseHeaders)
w.WriteHeader(res.Content.HttpStatusCode())
if agg.handleForwardingRequests(res, w, r) {
Copy link
Member

Choose a reason for hiding this comment

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

The name is IMO not self explaining: what's about handle30xResponses()

w.WriteHeader(res.Content.HttpStatusCode())
io.Copy(w, res.Content.Reader())
res.Content.Reader().Close()
if agg.handleRequestsWithBody(res, w, r) {
Copy link
Member

Choose a reason for hiding this comment

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

Here, I would suggest the name: handleStreamResponses

It would also be a good idea to put both cases within the loop in one method with the name:
handleNonMergeableResponses()

@@ -83,31 +81,83 @@ func (agg *CompositionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
}
}

status := 200
status := agg.extractStatusCode(results, w, r)
Copy link
Member

Choose a reason for hiding this comment

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

Also this function name is missleading, because the basic work it does is to copy the headers.
Maybe the two things: Extraction of the status code and copy the header should be done in separate steps.

* go format
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.812% when pulling 13f46bb on bugfix/1463-enabled-head-requests into d4e78f0 on master.

@smancke
Copy link
Member

smancke commented Nov 21, 2016

Cool, looks very clean and understandable, now!
So, from my side fine to merge it.

This was referenced Nov 21, 2016
@deberth deberth merged commit 475d8ec into master Nov 22, 2016
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.

None yet

4 participants