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

Send the correct 'Host' header when upgrading. #100

Merged
merged 1 commit into from
Feb 2, 2016

Conversation

trustin
Copy link
Member

@trustin trustin commented Jan 28, 2016

Related: #98

Motivation:

HttpSessionChannelFactory keeps the cached map from SessionProtocol to
Bootstrap. The cached Bootstrap configures its new Channels to send the
name of the target host with an H1C-to-H2C upgrade request.

Unfortunately, The cached Bootstrap does not determine the target host
name dynamically but just uses the initially specified one, and this
makes a client send a wrong 'Host' header when a pool creates a new
connection with a different target host name and with the same
SessionProtocol.

Modifications:

  • HttpConfigurator doesn't require a 'host' parameter anymore. It
    retrieves the target host name by intercepting the 'connect()'
    operation.
  • Add HttpHostHeaderUtil that creates 'Host' header value correctly
    • Use HttpHostHeaderUtil.hostHeader() in HttpConfigurator and
      HttpSessionHandler to reduce code duplication
  • Miscellaneous:
    • Replace HttpRemoteInvoker.poolKey() with direct constructor call
    • Fix the API documentation of ServiceInvocationContext.host()
    • Reorganize the methods and inner classes in HttpConfigurator
    • Remove ByteBufOverHttpCodec which is not used anymore

Result:

  • Armeria client sends the correct 'Host' header when it sends a upgrade
    request.
  • Description of ServiceInvocationContext.host() is not misleading
    anymore.

@trustin trustin added the defect label Jan 28, 2016
@trustin trustin added this to the 0.9.0.Final milestone Jan 28, 2016
@trustin trustin force-pushed the fix_h2c_upgrade_request branch 3 times, most recently from 7cde51a to f05ffff Compare January 28, 2016 09:50
@trustin
Copy link
Member Author

trustin commented Jan 28, 2016

@anuraaga PTAL

}

final StringBuilder buf = new StringBuilder(host.length() + 6);
buf.append(host);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Chain methods

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@anuraaga
Copy link
Collaborator

Just one nit

Related: line#98

Motivation:

HttpSessionChannelFactory keeps the cached map from SessionProtocol to
Bootstrap. The cached Bootstrap configures its new Channels to send the
name of the target host with an H1C-to-H2C upgrade request.

Unfortunately, The cached Bootstrap does not determine the target host
name dynamically but just uses the initially specified one, and this
makes a client send a wrong 'Host' header when a pool creates a new
connection with a different target host name and with the same
SessionProtocol.

Modifications:

- HttpConfigurator doesn't require a 'host' parameter anymore. It
  retrieves the target host name by intercepting the 'connect()'
  operation.
- Add HttpHostHeaderUtil that creates 'Host' header value correctly
  - Use HttpHostHeaderUtil.hostHeader() in HttpConfigurator and
    HttpSessionHandler to reduce code duplication
- Miscellaneous:
  - Replace HttpRemoteInvoker.poolKey() with direct constructor call
  - Fix the API documentation of ServiceInvocationContext.host()
  - Reorganize the methods and inner classes in HttpConfigurator
  - Remove ByteBufOverHttpCodec which is not used anymore

Result:

- Armeria client sends the correct 'Host' header when it sends a upgrade
  request.
- Description of ServiceInvocationContext.host() is not misleading
  anymore.
@trustin
Copy link
Member Author

trustin commented Feb 2, 2016

@anuraaga Addressed the nit

anuraaga added a commit that referenced this pull request Feb 2, 2016
Send the correct 'Host' header when upgrading.
@anuraaga anuraaga merged commit 10ff52e into line:master Feb 2, 2016
@trustin trustin deleted the fix_h2c_upgrade_request branch February 2, 2016 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants