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

[HttpKernel] renamed sub-request classes #6871

Closed
wants to merge 4 commits into from

Conversation

kriswallsmith
Copy link
Contributor

The name "HTTP content renderer" was too vague for me, so I renamed things to jive with the concept of sub-requests, which is more specific. I've also renamed the "default" strategy to "inline," which is more descriptive (see #6829).

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

about trusted proxies

The hinclude strategy should respond to any client IP but the esi strategy should only respond to configured IP addresses. This suggests checking IP should happen downstream of the listener…

about config.yml

I would also like to rework the esi and router_proxy sections of config.yml info one sub_request section that looks something like this…

framework:
    # ...
    sub_request:
        listener:
            enabled: true
            prefix: /_proxy
        esi:
            enabled: true
            trusted_ips: "%kernel.trusted_proxies%"
        hinclude:
            enabled: true

I've changed path to prefix here so the URI could explicitly tell the listener which strategy to call up, allowing that strategy to check the IP address if necessary. For example, /_proxy/esi?… would be caught by the listener, which would then look for an esi strategy, which would check the client IP. A similar request for /_proxy/hinclude?… would call up the hinclude strategy, which would not check the client IP.

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

esi under sub_request does not seem right to me.

👍 for "inline"

@kriswallsmith
Copy link
Contributor Author

@vicb Can you say why? We've created a little sub-framework for how sub-requests are rendered and ESI is one of many possible strategies.

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

esi requests are master requests

@kriswallsmith
Copy link
Contributor Author

That's an interesting point. If an ESI request is handled by HttpCache it is flagged as a sub-request. However if the request comes from an external proxy it appears to be handled as a master request.

I'm curious to hear what @fabpot thinks of this discrepancy?

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

Hinc are also master. We should come with something better than subrequest imo.

@kriswallsmith
Copy link
Contributor Author

I lean the other way… those ESI and hinclude requests should be handled as sub-requests. Not sure how that would work though.

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

I think per strategy config is covered by an issue from Fabien with a broader scope

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

those ESI and hinclude requests should be handled as sub-requests

How ? IMO this is not possible by design !

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

We should come with something better than subrequest imo.

Here I mean the name of the key, ie sub_request

@kriswallsmith
Copy link
Contributor Author

One possibility…

$response = $kernel->handle($request, $kernel->detectRequestType($request));

…where ->detectRequestType() checks for the path prefix and returns the appropriate flag.

@kriswallsmith
Copy link
Contributor Author

Or change the ->handle() signature to…

public function handle(Request $request, $type = null, $catch = true);

…and call ->detectRequestType() when null === $type.

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

but why ? that would a sub-request w/o master and the code would break in some places I think.

@kriswallsmith
Copy link
Contributor Author

Because a sub-request should always be marked as a sub-request. Can you be more specific about what would break? It's my understanding that sub-requests have no knowledge of their parent request, whether it exists in the same process or not.

@vicb
Copy link
Contributor

vicb commented Jan 25, 2013

But Kris it's the browser or the rp that makes an other master request (on misses) it not a sub request.

@kriswallsmith
Copy link
Contributor Author

You are correct if your definition of a sub-request is that it must occur in the same process as a master request. I do not agree with this definition, however. My concern is that a {{ render() }} tag will be flagged as a sub-request in development but be handled as a master request in production and the unexpected behaviors this may cause.

@vicb
Copy link
Contributor

vicb commented Jan 26, 2013

To me a master request "is" an HTTP request while a sub-request is something internal to Sf (which implies the same process). I admit I fail to see what a sub-request as an HTTP request would be and why it would be useful ? Is it only because esi requests are sub-requests when HttpCache is used ? (which is not exactly what you said in the previous comment)

@kriswallsmith
Copy link
Contributor Author

Closing in favor of #6925

fabpot added a commit to fabpot/symfony that referenced this pull request Jan 31, 2013
symfony#6871)

HttpContentRenderer has been renamed to FragmentHandler.
The RendererStrategy subnamespace has been renamed to Fragment.
The strategy classes now have Fragment in their names.
ProxyRouterListener has been renamed to FragmentListener
The router_proxy configuration entry has been renamed to fragments.
fabpot added a commit that referenced this pull request Feb 1, 2013
#6871)

HttpContentRenderer has been renamed to FragmentHandler.
The RendererStrategy subnamespace has been renamed to Fragment.
The strategy classes now have Fragment in their names.
ProxyRouterListener has been renamed to FragmentListener
The router_proxy configuration entry has been renamed to fragments.
fabpot added a commit that referenced this pull request Feb 1, 2013
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #6925).

Commits
-------

0586643 renamed some classes and Twig functions to more descriptive names (refs #6871)

Discussion
----------

renamed some classes and Twig functions to more descriptive names (refs #6871)

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6871
| License       | MIT
| Doc PR        | symfony/symfony-docs#2205

Todo:

 - [x] update the docs

In #6871, @kriswallsmith wondered if the names used for the ESI/HIncludes sub-framework were meaningful enough.

I agree that this was not the case and I propose to remove the notion of **sub-requests** in favor of **fragments**. This sub-framework is a way to render fragments of a resource (the fact that it's done via another request is an implementation detail).

With that decision, all names can be renamed and are probably more meaningful. Some examples:

* `HttpContentRenderer` -> `FragmentHandler`
* `RouterProxyListener` -> `FragmentListener`
* `router_proxy` -> `fragments` (configuration entry)
* `DefaultRenderingStrategy` -> `InlineFragmentRenderer`

---------------------------------------------------------------------------

by fabpot at 2013-01-31T09:50:14Z

I forgot to mention that this renaming will also probably help documenting the feature as understanding the notion of a fragment is probably easier.

---------------------------------------------------------------------------

by Tobion at 2013-01-31T14:18:40Z

I'd like to say again that the word `render` in `FragmentRenderingStrategy` does not fit because it's not about rendering (that's left to the templating) of a fragment.
I suggest to rename it to `FragmentInclusionStrategy` because it defines the strategy to include the fragment.
This is also consistent with every strategy there is:
- ESI: `<esi:include`
- SSI: `<!--#include file="header.shtml" -->`
- hinclude (even in the name)
- inline (similar to phps `include()`)

---------------------------------------------------------------------------

by fabpot at 2013-01-31T14:48:07Z

I've just renamed `FragmentRenderer` to `FragmentHandler` and strategies like `EsiFragmentRenderingStrategy` to `EsiFragmentRenderer` (and everything is put into a new `Fragment` sub-namespace).

---------------------------------------------------------------------------

by fabpot at 2013-01-31T21:11:44Z

I've reverted the Twig function name change as the current name is more expressive with its arguments: `render(controller(...))` or `render_esi(url(...))`.
fabpot added a commit that referenced this pull request Feb 4, 2013
* 2.2:
  fixed regression in the Finder component (it was possible to use it without using exec before, closes #6357)
  fixed a circular call (closes #6864)
  typo
  [Security] [Tests] added unit tests for the UserPasswordValidator class and made the validator service for the UserPassword constraint configurable.
  fixed wrong indentation
  tweaked previous commit
  [HttpKernel] Fix the URI signer (closes #6801)
  Add Arabic translations.
  [HttpKernel] fixed regression when rendering an inline controller and passing some objects  (closes #6822)
  [FrameworkBundle] fixed typo
  renamed some classes and Twig functions to more descriptive names (refs #6871)
  Classcollectionloader: fix traits + enhancements
  Fix a deprecated method call in the tests
  Update `composer.json` files: - to allow versions ~2.2 (>=2.2,<3.0) of Doctrine DBAL, ORM & Common - fixed Propel1 versions difference between main and bridge files - fixed Twig versions difference between main and bridge files - to allow versions ~1.11 (>=1.11,<2.0) of Twig - fixed Locale ext-intl version to accept all, not non-existing version
  Correct comment in NativeSessionStorage regarding session.save_handler
  [Security] Add PHPDoc to AuthenticationEvents
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.

2 participants