Skip to content

Skip rendering of template by the autopage handler on HTTP methods other than GET - #1140

Closed
racke wants to merge 1 commit into
PerlDancer:masterfrom
racke:pr/autopage-template
Closed

racke wants to merge 1 commit into
PerlDancer:masterfrom
racke:pr/autopage-template

Conversation

@racke

@racke racke commented Mar 11, 2016

Copy link
Copy Markdown
Member

Tiny optimization for autopage handler - it doesn't make sense to render the template and throw it away.

@veryrusty

Copy link
Copy Markdown
Member

rfc 1945 - HTTP 1.0 section 8.2 and (the obsolete) rfc 2616 - HTTP 1.1 state

The metainformation contained in the HTTP headers in response to a HEAD request should be identical to the information sent in response to a GET request

i.e. A HEAD request should include a Content-Length header.

Whereas rfc 7231 - HTTP 1.1 section 4.3.2 allows Content-Length header to be missing.

After #1139 was merged, the remaining logic in the AutoPage handler this Pr is optimising does need some cleaning up. However, I think we should always render the content and let our middleware stack remove the body for a HEAD request, so the Content-Length header is included in the response.

@veryrusty

Copy link
Copy Markdown
Member

and .. @racke++ for picking up that the logic needs cleaning up there!

@xsawyerx

Copy link
Copy Markdown
Member

I think we should benchmark not using the Head middleware. If we're already at the spot where we have the body and headers and we can just remove the body, that will save at least two subroutine calls per request for a single if() condition. It's much better.

(Some of the optimizations I did in D2 to make it faster than D1 was removing unnecessary middlewares - it made a big difference.)

@xsawyerx

xsawyerx commented May 26, 2016 •

Copy link
Copy Markdown
Member

So, so summarize:

  • I agree with @veryrusty on the spec. HEAD should be GET minus the content, meaning we do need to run the GET, just not return the content.
  • I will open a different ticket to remove the HEAD middleware. Middlewares are more expensive than we assume.

Should we close this issue?

@xsawyerx

Copy link
Copy Markdown
Member

Done - #1170.

@cromedome

Copy link
Copy Markdown
Contributor

Doing some housekeeping... looking at this PR, the ensuing discussion, and #1170, is it ok to close this? I am inclined to. Thanks!

@SysPete

SysPete commented Mar 29, 2020

Copy link
Copy Markdown
Member

@cromedome agree: time to close this one.

@cromedome

Copy link
Copy Markdown
Contributor

Thanks!

@cromedome cromedome closed this Mar 30, 2020
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.

5 participants