private void setUpgradeRequestHeaders ( ChannelHandlerContext ctx , HttpRequest request ) { // Set the UPGRADE header on the request. request . headers ( ) . set ( HttpHeaderNames . UPGRADE , upgradeCodec . protocol ( ) ) ; // Add all protocol-specific headers to the request. Set < CharSequence > connectionParts = new LinkedHashSet < CharSequence > ( 2 ) ; connectionParts . addAll ( upgradeCodec . setUpgradeHeaders ( ctx , request ) ) ; // Set the CONNECTION header from the set of all protocol-specific headers that were added. StringBuilder builder = new StringBuilder ( ) ; for ( CharSequence part : connectionParts ) { builder . append ( part ) ; builder . append ( ' ' ) ; } builder . append ( HttpHeaderValues . UPGRADE ) ; request . headers ( ) . add ( HttpHeaderNames . CONNECTION , builder . toString ( ) ) ; }
Adds all upgrade request headers necessary for an upgrade to the supported protocols .