idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
10,400 | @ SuppressWarnings ( "unused" ) final void handleReasonPhrase ( ByteBuffer buffer , ResponseParseState state , HttpResponseBuilder builder ) { StringBuilder stringBuilder = state . stringBuilder ; while ( buffer . hasRemaining ( ) ) { final char next = ( char ) buffer . get ( ) ; if ( next == '\n' || next == '\r' ) { builder . setReasonPhrase ( stringBuilder . toString ( ) ) ; state . state = ResponseParseState . AFTER_REASON_PHRASE ; state . stringBuilder . setLength ( 0 ) ; state . parseState = 0 ; state . leftOver = ( byte ) next ; state . pos = 0 ; state . nextHeader = null ; return ; } else { stringBuilder . append ( next ) ; } } } | Parses the reason phrase . This is called from the generated bytecode . |
10,401 | protected static Map < String , HttpString > httpStrings ( ) { final Map < String , HttpString > results = new HashMap < > ( ) ; final Class [ ] classs = { Headers . class , Methods . class , Protocols . class } ; for ( Class < ? > c : classs ) { for ( Field field : c . getDeclaredFields ( ) ) { if ( field . getType ( ) . equals ( HttpString . class ) ) { field . setAccessible ( true ) ; HttpString result = null ; try { result = ( HttpString ) field . get ( null ) ; results . put ( result . toString ( ) , result ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } } } } return results ; } | This is a bit of hack to enable the parser to get access to the HttpString s that are sorted in the static fields of the relevant classes . This means that in most cases a HttpString comparison will take the fast path == route as they will be the same object |
10,402 | public HttpHandler createProxyHandler ( ) { return ProxyHandler . builder ( ) . setProxyClient ( container . getProxyClient ( ) ) . setMaxRequestTime ( maxRequestTime ) . setMaxConnectionRetries ( maxRetries ) . setReuseXForwarded ( reuseXForwarded ) . build ( ) ; } | Get the handler proxying the requests . |
10,403 | public synchronized void advertise ( MCMPConfig config ) throws IOException { final MCMPConfig . AdvertiseConfig advertiseConfig = config . getAdvertiseConfig ( ) ; if ( advertiseConfig == null ) { throw new IllegalArgumentException ( "advertise not enabled" ) ; } MCMPAdvertiseTask . advertise ( container , advertiseConfig , xnioWorker ) ; } | Start advertising a mcmp handler . |
10,404 | private static boolean isV0Separator ( final char c ) { if ( c < 0x20 || c >= 0x7f ) { if ( c != 0x09 ) { throw UndertowMessages . MESSAGES . invalidControlCharacter ( Integer . toString ( c ) ) ; } } return V0_SEPARATOR_FLAGS [ c ] ; } | Returns true if the byte is a separator as defined by V0 of the cookie spec . |
10,405 | private static boolean isHttpSeparator ( final char c ) { if ( c < 0x20 || c >= 0x7f ) { if ( c != 0x09 ) { throw UndertowMessages . MESSAGES . invalidControlCharacter ( Integer . toString ( c ) ) ; } } return HTTP_SEPARATOR_FLAGS [ c ] ; } | Returns true if the byte is a separator as defined by V1 of the cookie spec RFC2109 . |
10,406 | public static void maybeQuote ( StringBuilder buf , String value ) { if ( value == null || value . length ( ) == 0 ) { buf . append ( "\"\"" ) ; } else if ( alreadyQuoted ( value ) ) { buf . append ( '"' ) ; buf . append ( escapeDoubleQuotes ( value , 1 , value . length ( ) - 1 ) ) ; buf . append ( '"' ) ; } else if ( ( isHttpToken ( value ) && ! ALLOW_HTTP_SEPARATORS_IN_V0 ) || ( isV0Token ( value ) && ALLOW_HTTP_SEPARATORS_IN_V0 ) ) { buf . append ( '"' ) ; buf . append ( escapeDoubleQuotes ( value , 0 , value . length ( ) ) ) ; buf . append ( '"' ) ; } else { buf . append ( value ) ; } } | Quotes values if required . |
10,407 | private static String escapeDoubleQuotes ( String s , int beginIndex , int endIndex ) { if ( s == null || s . length ( ) == 0 || s . indexOf ( '"' ) == - 1 ) { return s ; } StringBuilder b = new StringBuilder ( ) ; for ( int i = beginIndex ; i < endIndex ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '\\' ) { b . append ( c ) ; if ( ++ i >= endIndex ) throw UndertowMessages . MESSAGES . invalidEscapeCharacter ( ) ; b . append ( s . charAt ( i ) ) ; } else if ( c == '"' ) b . append ( '\\' ) . append ( '"' ) ; else b . append ( c ) ; } return b . toString ( ) ; } | Escapes any double quotes in the given string . |
10,408 | static byte [ ] removeAlpnExtensionsFromServerHello ( ByteBuffer source , final AtomicReference < String > selectedAlpnProtocol ) throws SSLException { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; try { exploreHandshake ( source , source . remaining ( ) , selectedAlpnProtocol , out ) ; int serverHelloLength = out . size ( ) - 4 ; byte [ ] data = out . toByteArray ( ) ; data [ 1 ] = ( byte ) ( ( serverHelloLength >> 16 ) & 0xFF ) ; data [ 2 ] = ( byte ) ( ( serverHelloLength >> 8 ) & 0xFF ) ; data [ 3 ] = ( byte ) ( serverHelloLength & 0xFF ) ; return data ; } catch ( AlpnProcessingException e ) { return null ; } } | removes the ALPN extensions from the server hello |
10,409 | public ModClusterProxyTarget findTarget ( final HttpServerExchange exchange ) { final PathMatcher . PathMatch < VirtualHost . HostEntry > entry = mapVirtualHost ( exchange ) ; if ( entry == null ) { return null ; } for ( final Balancer balancer : balancers . values ( ) ) { final Map < String , Cookie > cookies = exchange . getRequestCookies ( ) ; if ( balancer . isStickySession ( ) ) { if ( cookies . containsKey ( balancer . getStickySessionCookie ( ) ) ) { String sessionId = cookies . get ( balancer . getStickySessionCookie ( ) ) . getValue ( ) ; Iterator < CharSequence > routes = parseRoutes ( sessionId ) ; if ( routes . hasNext ( ) ) { return new ModClusterProxyTarget . ExistingSessionTarget ( sessionId , routes , entry . getValue ( ) , this , balancer . isStickySessionForce ( ) ) ; } } if ( exchange . getPathParameters ( ) . containsKey ( balancer . getStickySessionPath ( ) ) ) { String sessionId = exchange . getPathParameters ( ) . get ( balancer . getStickySessionPath ( ) ) . getFirst ( ) ; Iterator < CharSequence > jvmRoute = parseRoutes ( sessionId ) ; if ( jvmRoute . hasNext ( ) ) { return new ModClusterProxyTarget . ExistingSessionTarget ( sessionId , jvmRoute , entry . getValue ( ) , this , balancer . isStickySessionForce ( ) ) ; } } } } return new ModClusterProxyTarget . BasicTarget ( entry . getValue ( ) , this ) ; } | Get the mod_cluster proxy target . |
10,410 | public synchronized boolean addNode ( final NodeConfig config , final Balancer . BalancerBuilder balancerConfig , final XnioIoThread ioThread , final ByteBufferPool bufferPool ) { final String jvmRoute = config . getJvmRoute ( ) ; final Node existing = nodes . get ( jvmRoute ) ; if ( existing != null ) { if ( config . getConnectionURI ( ) . equals ( existing . getNodeConfig ( ) . getConnectionURI ( ) ) ) { existing . resetState ( ) ; return true ; } else { existing . markRemoved ( ) ; removeNode ( existing ) ; if ( ! existing . isInErrorState ( ) ) { return false ; } } } final String balancerRef = config . getBalancer ( ) ; Balancer balancer = balancers . get ( balancerRef ) ; if ( balancer != null ) { UndertowLogger . ROOT_LOGGER . debugf ( "Balancer %s already exists, replacing" , balancerRef ) ; } balancer = balancerConfig . build ( ) ; balancers . put ( balancerRef , balancer ) ; final Node node = new Node ( config , balancer , ioThread , bufferPool , this ) ; nodes . put ( jvmRoute , node ) ; scheduleHealthCheck ( node , ioThread ) ; if ( updateLoadTask . cancelKey == null ) { updateLoadTask . cancelKey = ioThread . executeAtInterval ( updateLoadTask , modCluster . getHealthCheckInterval ( ) , TimeUnit . MILLISECONDS ) ; } failoverDomains . remove ( node . getJvmRoute ( ) ) ; UndertowLogger . ROOT_LOGGER . registeringNode ( jvmRoute , config . getConnectionURI ( ) ) ; return true ; } | Register a new node . |
10,411 | public synchronized boolean enableNode ( final String jvmRoute ) { final Node node = nodes . get ( jvmRoute ) ; if ( node != null ) { for ( final Context context : node . getContexts ( ) ) { context . enable ( ) ; } return true ; } return false ; } | Management command enabling all contexts on the given node . |
10,412 | public synchronized boolean disableNode ( final String jvmRoute ) { final Node node = nodes . get ( jvmRoute ) ; if ( node != null ) { for ( final Context context : node . getContexts ( ) ) { context . disable ( ) ; } return true ; } return false ; } | Management command disabling all contexts on the given node . |
10,413 | public synchronized boolean stopNode ( final String jvmRoute ) { final Node node = nodes . get ( jvmRoute ) ; if ( node != null ) { for ( final Context context : node . getContexts ( ) ) { context . stop ( ) ; } return true ; } return false ; } | Management command stopping all contexts on the given node . |
10,414 | public synchronized boolean enableContext ( final String contextPath , final String jvmRoute , final List < String > aliases ) { final Node node = nodes . get ( jvmRoute ) ; if ( node != null ) { Context context = node . getContext ( contextPath , aliases ) ; if ( context == null ) { context = node . registerContext ( contextPath , aliases ) ; UndertowLogger . ROOT_LOGGER . registeringContext ( contextPath , jvmRoute ) ; UndertowLogger . ROOT_LOGGER . registeringContext ( contextPath , jvmRoute , aliases ) ; for ( final String alias : aliases ) { VirtualHost virtualHost = hosts . get ( alias ) ; if ( virtualHost == null ) { virtualHost = new VirtualHost ( ) ; hosts . put ( alias , virtualHost ) ; } virtualHost . registerContext ( contextPath , jvmRoute , context ) ; } } context . enable ( ) ; return true ; } return false ; } | Register a web context . If the web context already exists just enable it . |
10,415 | Context findNewNode ( final VirtualHost . HostEntry entry ) { return electNode ( entry . getContexts ( ) , false , null ) ; } | Find a new node handling this request . |
10,416 | Context findFailoverNode ( final VirtualHost . HostEntry entry , final String domain , final String session , final String jvmRoute , final boolean forceStickySession ) { if ( modCluster . isDeterministicFailover ( ) ) { List < String > candidates = new ArrayList < > ( entry . getNodes ( ) . size ( ) ) ; for ( String route : entry . getNodes ( ) ) { Node node = nodes . get ( route ) ; if ( node != null && ! node . isInErrorState ( ) && ! node . isHotStandby ( ) ) { candidates . add ( route ) ; } } if ( candidates . isEmpty ( ) ) { for ( String route : entry . getNodes ( ) ) { Node node = nodes . get ( route ) ; if ( node != null && ! node . isInErrorState ( ) && node . isHotStandby ( ) ) { candidates . add ( route ) ; } } } if ( candidates . isEmpty ( ) ) { return null ; } String sessionId = session . substring ( 0 , session . indexOf ( '.' ) ) ; int index = ( int ) ( Math . abs ( ( long ) sessionId . hashCode ( ) ) % candidates . size ( ) ) ; Collections . sort ( candidates ) ; String electedRoute = candidates . get ( index ) ; UndertowLogger . ROOT_LOGGER . debugf ( "Using deterministic failover target: %s" , electedRoute ) ; return entry . getContextForNode ( electedRoute ) ; } String failOverDomain = null ; if ( domain == null ) { final Node node = nodes . get ( jvmRoute ) ; if ( node != null ) { failOverDomain = node . getNodeConfig ( ) . getDomain ( ) ; } if ( failOverDomain == null ) { failOverDomain = failoverDomains . get ( jvmRoute ) ; } } else { failOverDomain = domain ; } final Collection < Context > contexts = entry . getContexts ( ) ; if ( failOverDomain != null ) { final Context context = electNode ( contexts , true , failOverDomain ) ; if ( context != null ) { return context ; } } if ( forceStickySession ) { return null ; } else { return electNode ( contexts , false , null ) ; } } | Try to find a failover node within the same load balancing group . |
10,417 | private PathMatcher . PathMatch < VirtualHost . HostEntry > mapVirtualHost ( final HttpServerExchange exchange ) { final String context = exchange . getRelativePath ( ) ; if ( modCluster . isUseAlias ( ) ) { final String hostName = exchange . getRequestHeaders ( ) . getFirst ( Headers . HOST ) ; if ( hostName != null ) { int i = hostName . indexOf ( ":" ) ; VirtualHost host ; if ( i > 0 ) { host = hosts . get ( hostName . substring ( 0 , i ) ) ; if ( host == null ) { host = hosts . get ( hostName ) ; } } else { host = hosts . get ( hostName ) ; } if ( host == null ) { return null ; } PathMatcher . PathMatch < VirtualHost . HostEntry > result = host . match ( context ) ; if ( result . getValue ( ) == null ) { return null ; } return result ; } } else { for ( Map . Entry < String , VirtualHost > host : hosts . entrySet ( ) ) { PathMatcher . PathMatch < VirtualHost . HostEntry > result = host . getValue ( ) . match ( context ) ; if ( result . getValue ( ) != null ) { return result ; } } } return null ; } | Map a request to virtual host . |
10,418 | public static long transfer ( final ReadableByteChannel source , final long count , final ByteBuffer throughBuffer , final WritableByteChannel sink ) throws IOException { long total = 0L ; while ( total < count ) { throughBuffer . clear ( ) ; if ( count - total < throughBuffer . remaining ( ) ) { throughBuffer . limit ( ( int ) ( count - total ) ) ; } try { long res = source . read ( throughBuffer ) ; if ( res <= 0 ) { return total == 0L ? res : total ; } } finally { throughBuffer . flip ( ) ; } while ( throughBuffer . hasRemaining ( ) ) { long res = sink . write ( throughBuffer ) ; if ( res <= 0 ) { return total ; } total += res ; } } return total ; } | Transfer the data from the source to the sink using the given through buffer to pass data through . |
10,419 | public static void echoFrame ( final WebSocketChannel channel , final StreamSourceFrameChannel ws ) throws IOException { final WebSocketFrameType type ; switch ( ws . getType ( ) ) { case PONG : ws . close ( ) ; return ; case PING : type = WebSocketFrameType . PONG ; break ; default : type = ws . getType ( ) ; break ; } final StreamSinkFrameChannel sink = channel . send ( type ) ; sink . setRsv ( ws . getRsv ( ) ) ; initiateTransfer ( ws , sink , new ChannelListener < StreamSourceFrameChannel > ( ) { public void handleEvent ( StreamSourceFrameChannel streamSourceFrameChannel ) { IoUtils . safeClose ( streamSourceFrameChannel ) ; } } , new ChannelListener < StreamSinkFrameChannel > ( ) { public void handleEvent ( StreamSinkFrameChannel streamSinkFrameChannel ) { try { streamSinkFrameChannel . shutdownWrites ( ) ; } catch ( IOException e ) { UndertowLogger . REQUEST_IO_LOGGER . ioException ( e ) ; IoUtils . safeClose ( streamSinkFrameChannel , channel ) ; return ; } try { if ( ! streamSinkFrameChannel . flush ( ) ) { streamSinkFrameChannel . getWriteSetter ( ) . set ( ChannelListeners . flushingChannelListener ( new ChannelListener < StreamSinkFrameChannel > ( ) { public void handleEvent ( StreamSinkFrameChannel streamSinkFrameChannel ) { streamSinkFrameChannel . getWriteSetter ( ) . set ( null ) ; IoUtils . safeClose ( streamSinkFrameChannel ) ; if ( type == WebSocketFrameType . CLOSE ) { IoUtils . safeClose ( channel ) ; } } } , new ChannelExceptionHandler < StreamSinkFrameChannel > ( ) { public void handleException ( StreamSinkFrameChannel streamSinkFrameChannel , IOException e ) { UndertowLogger . REQUEST_IO_LOGGER . ioException ( e ) ; IoUtils . safeClose ( streamSinkFrameChannel , channel ) ; } } ) ) ; streamSinkFrameChannel . resumeWrites ( ) ; } else { if ( type == WebSocketFrameType . CLOSE ) { IoUtils . safeClose ( channel ) ; } streamSinkFrameChannel . getWriteSetter ( ) . set ( null ) ; IoUtils . safeClose ( streamSinkFrameChannel ) ; } } catch ( IOException e ) { UndertowLogger . REQUEST_IO_LOGGER . ioException ( e ) ; IoUtils . safeClose ( streamSinkFrameChannel , channel ) ; } } } , new ChannelExceptionHandler < StreamSourceFrameChannel > ( ) { public void handleException ( StreamSourceFrameChannel streamSourceFrameChannel , IOException e ) { UndertowLogger . REQUEST_IO_LOGGER . ioException ( e ) ; IoUtils . safeClose ( streamSourceFrameChannel , channel ) ; } } , new ChannelExceptionHandler < StreamSinkFrameChannel > ( ) { public void handleException ( StreamSinkFrameChannel streamSinkFrameChannel , IOException e ) { UndertowLogger . REQUEST_IO_LOGGER . ioException ( e ) ; IoUtils . safeClose ( streamSinkFrameChannel , channel ) ; } } , channel . getBufferPool ( ) ) ; } | Echo back the frame to the sender |
10,420 | public long fastIterate ( ) { final Object [ ] table = this . table ; final int len = table . length ; int ri = 0 ; int ci ; while ( ri < len ) { final Object item = table [ ri ] ; if ( item != null ) { if ( item instanceof HeaderValues ) { return ( long ) ri << 32L ; } else { final HeaderValues [ ] row = ( HeaderValues [ ] ) item ; ci = 0 ; final int rowLen = row . length ; while ( ci < rowLen ) { if ( row [ ci ] != null ) { return ( long ) ri << 32L | ( ci & 0xffffffffL ) ; } ci ++ ; } } } ri ++ ; } return - 1L ; } | Do a fast iteration of this header map without creating any objects . |
10,421 | public long fiNextNonEmpty ( long cookie ) { if ( cookie == - 1L ) return - 1L ; final Object [ ] table = this . table ; final int len = table . length ; int ri = ( int ) ( cookie >> 32 ) ; int ci = ( int ) cookie ; Object item = table [ ri ] ; if ( item instanceof HeaderValues [ ] ) { final HeaderValues [ ] row = ( HeaderValues [ ] ) item ; final int rowLen = row . length ; if ( ++ ci >= rowLen ) { ri ++ ; ci = 0 ; } else if ( row [ ci ] != null && ! row [ ci ] . isEmpty ( ) ) { return ( long ) ri << 32L | ( ci & 0xffffffffL ) ; } } else { ri ++ ; ci = 0 ; } while ( ri < len ) { item = table [ ri ] ; if ( item instanceof HeaderValues && ! ( ( HeaderValues ) item ) . isEmpty ( ) ) { return ( long ) ri << 32L ; } else if ( item instanceof HeaderValues [ ] ) { final HeaderValues [ ] row = ( HeaderValues [ ] ) item ; final int rowLen = row . length ; while ( ci < rowLen ) { if ( row [ ci ] != null && ! row [ ci ] . isEmpty ( ) ) { return ( long ) ri << 32L | ( ci & 0xffffffffL ) ; } ci ++ ; } } ci = 0 ; ri ++ ; } return - 1L ; } | Find the next non - empty index in a fast iteration . |
10,422 | public HeaderValues fiCurrent ( long cookie ) { try { final Object [ ] table = this . table ; int ri = ( int ) ( cookie >> 32 ) ; int ci = ( int ) cookie ; final Object item = table [ ri ] ; if ( item instanceof HeaderValues [ ] ) { return ( ( HeaderValues [ ] ) item ) [ ci ] ; } else if ( ci == 0 ) { return ( HeaderValues ) item ; } else { throw new NoSuchElementException ( ) ; } } catch ( RuntimeException e ) { throw new NoSuchElementException ( ) ; } } | Return the value at the current index in a fast iteration . |
10,423 | public static SSLEngine getSslEngine ( SslConnection connection ) { if ( connection instanceof UndertowSslConnection ) { return ( ( UndertowSslConnection ) connection ) . getSSLEngine ( ) ; } else { return JsseXnioSsl . getSslEngine ( connection ) ; } } | Get the SSL engine for a given connection . |
10,424 | private static SSLEngine createSSLEngine ( SSLContext sslContext , OptionMap optionMap , InetSocketAddress peerAddress , boolean client ) { final SSLEngine engine = sslContext . createSSLEngine ( optionMap . get ( Options . SSL_PEER_HOST_NAME , peerAddress . getHostString ( ) ) , optionMap . get ( Options . SSL_PEER_PORT , peerAddress . getPort ( ) ) ) ; engine . setUseClientMode ( client ) ; engine . setEnableSessionCreation ( optionMap . get ( Options . SSL_ENABLE_SESSION_CREATION , true ) ) ; final Sequence < String > cipherSuites = optionMap . get ( Options . SSL_ENABLED_CIPHER_SUITES ) ; if ( cipherSuites != null ) { final Set < String > supported = new HashSet < String > ( Arrays . asList ( engine . getSupportedCipherSuites ( ) ) ) ; final List < String > finalList = new ArrayList < String > ( ) ; for ( String name : cipherSuites ) { if ( supported . contains ( name ) ) { finalList . add ( name ) ; } } engine . setEnabledCipherSuites ( finalList . toArray ( new String [ finalList . size ( ) ] ) ) ; } final Sequence < String > protocols = optionMap . get ( Options . SSL_ENABLED_PROTOCOLS ) ; if ( protocols != null ) { final Set < String > supported = new HashSet < String > ( Arrays . asList ( engine . getSupportedProtocols ( ) ) ) ; final List < String > finalList = new ArrayList < String > ( ) ; for ( String name : protocols ) { if ( supported . contains ( name ) ) { finalList . add ( name ) ; } } engine . setEnabledProtocols ( finalList . toArray ( new String [ finalList . size ( ) ] ) ) ; } return engine ; } | Create a new SSL engine configured from an option map . |
10,425 | public synchronized void sendRetry ( long retry , EventCallback callback ) { if ( open == 0 || shutdown ) { if ( callback != null ) { callback . failed ( this , null , null , null , new ClosedChannelException ( ) ) ; } return ; } queue . add ( new SSEData ( retry , callback ) ) ; sink . getIoThread ( ) . execute ( new Runnable ( ) { public void run ( ) { synchronized ( ServerSentEventConnection . this ) { if ( pooled == null ) { fillBuffer ( ) ; writeListener . handleEvent ( sink ) ; } } } } ) ; } | Sends the retry message to the client instructing it how long to wait before attempting a reconnect . |
10,426 | public void shutdown ( ) { if ( open == 0 || shutdown ) { return ; } shutdown = true ; sink . getIoThread ( ) . execute ( new Runnable ( ) { public void run ( ) { synchronized ( ServerSentEventConnection . this ) { if ( queue . isEmpty ( ) && pooled == null ) { exchange . endExchange ( ) ; } } } } ) ; } | execute a graceful shutdown once all data has been sent |
10,427 | public static Map < Class < ? > , Boolean > getHandlerTypes ( Class < ? extends MessageHandler > clazz ) { Map < Class < ? > , Boolean > types = new IdentityHashMap < > ( 2 ) ; for ( Class < ? > c = clazz ; c != Object . class ; c = c . getSuperclass ( ) ) { exampleGenericInterfaces ( types , c , clazz ) ; } if ( types . isEmpty ( ) ) { throw JsrWebSocketMessages . MESSAGES . unknownHandlerType ( clazz ) ; } return types ; } | Returns a map of all supported message types by the given handler class . The key of the map is the supported message type ; the value indicates whether it is a partial message handler or not . |
10,428 | public static String toDateString ( final Date date ) { SimpleDateFormat df = RFC1123_PATTERN_FORMAT . get ( ) ; df . setTimeZone ( GMT_ZONE ) ; return df . format ( date ) ; } | Converts a date to a format suitable for use in a HTTP request |
10,429 | public static Date parseDate ( final String date ) { final int semicolonIndex = date . indexOf ( ';' ) ; final String trimmedDate = semicolonIndex >= 0 ? date . substring ( 0 , semicolonIndex ) : date ; ParsePosition pp = new ParsePosition ( 0 ) ; SimpleDateFormat dateFormat = RFC1123_PATTERN_FORMAT . get ( ) ; dateFormat . setTimeZone ( GMT_ZONE ) ; Date val = dateFormat . parse ( trimmedDate , pp ) ; if ( val != null && pp . getIndex ( ) == trimmedDate . length ( ) ) { return val ; } pp = new ParsePosition ( 0 ) ; dateFormat = new SimpleDateFormat ( RFC1036_PATTERN , LOCALE_US ) ; dateFormat . setTimeZone ( GMT_ZONE ) ; val = dateFormat . parse ( trimmedDate , pp ) ; if ( val != null && pp . getIndex ( ) == trimmedDate . length ( ) ) { return val ; } pp = new ParsePosition ( 0 ) ; dateFormat = new SimpleDateFormat ( ASCITIME_PATTERN , LOCALE_US ) ; dateFormat . setTimeZone ( GMT_ZONE ) ; val = dateFormat . parse ( trimmedDate , pp ) ; if ( val != null && pp . getIndex ( ) == trimmedDate . length ( ) ) { return val ; } pp = new ParsePosition ( 0 ) ; dateFormat = new SimpleDateFormat ( OLD_COOKIE_PATTERN , LOCALE_US ) ; dateFormat . setTimeZone ( GMT_ZONE ) ; val = dateFormat . parse ( trimmedDate , pp ) ; if ( val != null && pp . getIndex ( ) == trimmedDate . length ( ) ) { return val ; } return null ; } | Attempts to pass a HTTP date . |
10,430 | public static boolean handleIfUnmodifiedSince ( final HttpServerExchange exchange , final Date lastModified ) { return handleIfUnmodifiedSince ( exchange . getRequestHeaders ( ) . getFirst ( Headers . IF_UNMODIFIED_SINCE ) , lastModified ) ; } | Handles the if - unmodified - since header . returns true if the request should proceed false otherwise |
10,431 | public static String encodeString ( ByteBuffer source , boolean wrap ) { return Encoder . encodeString ( source , wrap , false ) ; } | Encodes a fixed and complete byte buffer into a Base64 String . |
10,432 | public static String encodeStringURL ( ByteBuffer source , boolean wrap ) { return Encoder . encodeString ( source , wrap , true ) ; } | Encodes a fixed and complete byte buffer into a Base64url String . |
10,433 | public static byte [ ] encodeBytes ( byte [ ] source , int pos , int limit , boolean wrap ) { return Encoder . encodeBytes ( source , pos , limit , wrap , false ) ; } | Encodes a fixed and complete byte buffer into a Base64 byte array . |
10,434 | public static byte [ ] encodeBytesURL ( byte [ ] source , int pos , int limit , boolean wrap ) { return Encoder . encodeBytes ( source , pos , limit , wrap , true ) ; } | Encodes a fixed and complete byte buffer into a Base64url byte array . |
10,435 | public static EncoderInputStream createEncoderInputStream ( InputStream source , int bufferSize , boolean wrap ) { return new EncoderInputStream ( source , bufferSize , wrap , false ) ; } | Creates an InputStream wrapper which encodes a source into base64 as it is read until the source hits EOF . Upon hitting EOF a standard base64 termination sequence will be readable . Clients can simply treat this input stream as if they were reading from a base64 encoded file . This stream attempts to read and encode in buffer size chunks from the source in order to improve overall performance . Thus BufferInputStream is not necessary and will lead to double buffering . |
10,436 | public static void sendContinueResponse ( final HttpServerExchange exchange , final IoCallback callback ) { if ( ! exchange . isResponseChannelAvailable ( ) ) { callback . onException ( exchange , null , UndertowMessages . MESSAGES . cannotSendContinueResponse ( ) ) ; return ; } internalSendContinueResponse ( exchange , callback ) ; } | Sends a continuation using async IO and calls back when it is complete . |
10,437 | public static ContinueResponseSender createResponseSender ( final HttpServerExchange exchange ) throws IOException { if ( ! exchange . isResponseChannelAvailable ( ) ) { throw UndertowMessages . MESSAGES . cannotSendContinueResponse ( ) ; } if ( exchange . getAttachment ( ALREADY_SENT ) != null ) { return new ContinueResponseSender ( ) { public boolean send ( ) throws IOException { return true ; } public void awaitWritable ( ) throws IOException { } public void awaitWritable ( long time , TimeUnit timeUnit ) throws IOException { } } ; } HttpServerExchange newExchange = exchange . getConnection ( ) . sendOutOfBandResponse ( exchange ) ; exchange . putAttachment ( ALREADY_SENT , true ) ; newExchange . setStatusCode ( StatusCodes . CONTINUE ) ; newExchange . getResponseHeaders ( ) . put ( Headers . CONTENT_LENGTH , 0 ) ; final StreamSinkChannel responseChannel = newExchange . getResponseChannel ( ) ; return new ContinueResponseSender ( ) { boolean shutdown = false ; public boolean send ( ) throws IOException { if ( ! shutdown ) { shutdown = true ; responseChannel . shutdownWrites ( ) ; } return responseChannel . flush ( ) ; } public void awaitWritable ( ) throws IOException { responseChannel . awaitWritable ( ) ; } public void awaitWritable ( final long time , final TimeUnit timeUnit ) throws IOException { responseChannel . awaitWritable ( time , timeUnit ) ; } } ; } | Creates a response sender that can be used to send a HTTP 100 - continue response . |
10,438 | public static void sendContinueResponseBlocking ( final HttpServerExchange exchange ) throws IOException { if ( ! exchange . isResponseChannelAvailable ( ) ) { throw UndertowMessages . MESSAGES . cannotSendContinueResponse ( ) ; } if ( exchange . getAttachment ( ALREADY_SENT ) != null ) { return ; } HttpServerExchange newExchange = exchange . getConnection ( ) . sendOutOfBandResponse ( exchange ) ; exchange . putAttachment ( ALREADY_SENT , true ) ; newExchange . setStatusCode ( StatusCodes . CONTINUE ) ; newExchange . getResponseHeaders ( ) . put ( Headers . CONTENT_LENGTH , 0 ) ; newExchange . startBlocking ( ) ; newExchange . getOutputStream ( ) . close ( ) ; newExchange . getInputStream ( ) . close ( ) ; } | Sends a continue response using blocking IO |
10,439 | public static void rejectExchange ( final HttpServerExchange exchange ) { exchange . setStatusCode ( StatusCodes . EXPECTATION_FAILED ) ; exchange . setPersistent ( false ) ; exchange . endExchange ( ) ; } | Sets a 417 response code and ends the exchange . |
10,440 | public static Predicate paths ( final String ... paths ) { final PathMatchPredicate [ ] predicates = new PathMatchPredicate [ paths . length ] ; for ( int i = 0 ; i < paths . length ; ++ i ) { predicates [ i ] = new PathMatchPredicate ( paths [ i ] ) ; } return or ( predicates ) ; } | Creates a predicate that returns true if any of the given paths match exactly . |
10,441 | public static Predicate suffixes ( final String ... paths ) { if ( paths . length == 1 ) { return suffix ( paths [ 0 ] ) ; } final PathSuffixPredicate [ ] predicates = new PathSuffixPredicate [ paths . length ] ; for ( int i = 0 ; i < paths . length ; ++ i ) { predicates [ i ] = new PathSuffixPredicate ( paths [ i ] ) ; } return or ( predicates ) ; } | Creates a predicate that returns true if the request path ends with any of the provided suffixes . |
10,442 | public static Predicate parse ( final String predicate ) { return PredicateParser . parse ( predicate , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } | parses the predicate string and returns the result using the TCCL to load predicate definitions |
10,443 | public static Predicate parse ( final String predicate , ClassLoader classLoader ) { return PredicateParser . parse ( predicate , classLoader ) ; } | parses the predicate string and returns the result |
10,444 | private void handleIndex ( int index ) throws HpackException { if ( index <= Hpack . STATIC_TABLE_LENGTH ) { addStaticTableEntry ( index ) ; } else { int adjustedIndex = getRealIndex ( index - Hpack . STATIC_TABLE_LENGTH ) ; HeaderField headerField = headerTable [ adjustedIndex ] ; headerEmitter . emitHeader ( headerField . name , headerField . value , false ) ; } } | Handle an indexed header representation |
10,445 | public static boolean sendRequestedBlobs ( HttpServerExchange exchange ) { ByteBuffer buffer = null ; String type = null ; String etag = null ; String quotedEtag = null ; if ( "css" . equals ( exchange . getQueryString ( ) ) ) { buffer = Blobs . FILE_CSS_BUFFER . duplicate ( ) ; type = "text/css" ; etag = Blobs . FILE_CSS_ETAG ; quotedEtag = Blobs . FILE_CSS_ETAG_QUOTED ; } else if ( "js" . equals ( exchange . getQueryString ( ) ) ) { buffer = Blobs . FILE_JS_BUFFER . duplicate ( ) ; type = "application/javascript" ; etag = Blobs . FILE_JS_ETAG ; quotedEtag = Blobs . FILE_JS_ETAG_QUOTED ; } if ( buffer != null ) { if ( ! ETagUtils . handleIfNoneMatch ( exchange , new ETag ( false , etag ) , false ) ) { exchange . setStatusCode ( StatusCodes . NOT_MODIFIED ) ; return true ; } exchange . getResponseHeaders ( ) . put ( Headers . CONTENT_LENGTH , String . valueOf ( buffer . limit ( ) ) ) ; exchange . getResponseHeaders ( ) . put ( Headers . CONTENT_TYPE , type ) ; exchange . getResponseHeaders ( ) . put ( Headers . ETAG , quotedEtag ) ; if ( Methods . HEAD . equals ( exchange . getRequestMethod ( ) ) ) { exchange . endExchange ( ) ; return true ; } exchange . getResponseSender ( ) . send ( buffer ) ; return true ; } return false ; } | Serve static resource for the directory listing |
10,446 | public WebSocketProtocolHandshakeHandler addExtension ( ExtensionHandshake extension ) { if ( extension != null ) { for ( Handshake handshake : handshakes ) { handshake . addExtension ( extension ) ; } } return this ; } | Add a new WebSocket Extension into the handshakes defined in this handler . |
10,447 | public static XnioExecutor . Key executeAfter ( XnioIoThread thread , Runnable task , long timeout , TimeUnit timeUnit ) { try { return thread . executeAfter ( task , timeout , timeUnit ) ; } catch ( RejectedExecutionException e ) { if ( thread . getWorker ( ) . isShutdown ( ) ) { UndertowLogger . ROOT_LOGGER . debugf ( e , "Failed to schedule task %s as worker is shutting down" , task ) ; return new XnioExecutor . Key ( ) { public boolean remove ( ) { return false ; } } ; } else { throw e ; } } } | Schedules a task for future execution . If the execution is rejected because the worker is shutting down then it is logged at debug level and the exception is not re - thrown |
10,448 | protected boolean isConfidential ( final HttpServerExchange exchange ) { ServletRequestContext src = exchange . getAttachment ( ServletRequestContext . ATTACHMENT_KEY ) ; if ( src != null ) { return src . getOriginalRequest ( ) . isSecure ( ) ; } return super . isConfidential ( exchange ) ; } | Use the HttpServerExchange supplied to check if this request is already sufficiently confidential . |
10,449 | public static String convertToHexString ( byte [ ] toBeConverted ) { if ( toBeConverted == null ) { throw new NullPointerException ( "Parameter to be converted can not be null" ) ; } char [ ] converted = new char [ toBeConverted . length * 2 ] ; for ( int i = 0 ; i < toBeConverted . length ; i ++ ) { byte b = toBeConverted [ i ] ; converted [ i * 2 ] = HEX_CHARS [ b >> 4 & 0x0F ] ; converted [ i * 2 + 1 ] = HEX_CHARS [ b & 0x0F ] ; } return String . valueOf ( converted ) ; } | Take the supplied byte array and convert it to a hex encoded String . |
10,450 | public static void flattenCookies ( final HttpServerExchange exchange ) { Map < String , Cookie > cookies = exchange . getResponseCookiesInternal ( ) ; boolean enableRfc6265Validation = exchange . getConnection ( ) . getUndertowOptions ( ) . get ( UndertowOptions . ENABLE_RFC6265_COOKIE_VALIDATION , UndertowOptions . DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION ) ; if ( cookies != null ) { for ( Map . Entry < String , Cookie > entry : cookies . entrySet ( ) ) { exchange . getResponseHeaders ( ) . add ( Headers . SET_COOKIE , getCookieString ( entry . getValue ( ) , enableRfc6265Validation ) ) ; } } } | Flattens the exchange cookie map into the response header map . This should be called by a connector just before the response is started . |
10,451 | public static void ungetRequestBytes ( final HttpServerExchange exchange , PooledByteBuffer ... buffers ) { PooledByteBuffer [ ] existing = exchange . getAttachment ( HttpServerExchange . BUFFERED_REQUEST_DATA ) ; PooledByteBuffer [ ] newArray ; if ( existing == null ) { newArray = new PooledByteBuffer [ buffers . length ] ; System . arraycopy ( buffers , 0 , newArray , 0 , buffers . length ) ; } else { newArray = new PooledByteBuffer [ existing . length + buffers . length ] ; System . arraycopy ( existing , 0 , newArray , 0 , existing . length ) ; System . arraycopy ( buffers , 0 , newArray , existing . length , buffers . length ) ; } exchange . putAttachment ( HttpServerExchange . BUFFERED_REQUEST_DATA , newArray ) ; exchange . addExchangeCompleteListener ( BufferedRequestDataCleanupListener . INSTANCE ) ; } | Attached buffered data to the exchange . The will generally be used to allow data to be re - read . |
10,452 | public static void verifyToken ( HttpString header ) { int length = header . length ( ) ; for ( int i = 0 ; i < length ; ++ i ) { byte c = header . byteAt ( i ) ; if ( ! ALLOWED_TOKEN_CHARACTERS [ c ] ) { throw UndertowMessages . MESSAGES . invalidToken ( c ) ; } } } | Verifies that the contents of the HttpString are a valid token according to rfc7230 . |
10,453 | public void resetBuffer ( ) { if ( anyAreSet ( state , FLAG_WRITE_STARTED ) ) { throw UndertowMessages . MESSAGES . cannotResetBuffer ( ) ; } buffer = null ; IoUtils . safeClose ( pooledBuffer ) ; pooledBuffer = null ; } | If the response has not yet been written to the client this method will clear the streams buffer invalidating any content that has already been written . If any content has already been sent to the client then this method will throw and IllegalStateException |
10,454 | private boolean performFlushIfRequired ( ) throws IOException { if ( anyAreSet ( state , FLUSHING_BUFFER ) ) { final ByteBuffer [ ] bufs = new ByteBuffer [ additionalBuffer == null ? 1 : 2 ] ; long totalLength = 0 ; bufs [ 0 ] = currentBuffer . getBuffer ( ) ; totalLength += bufs [ 0 ] . remaining ( ) ; if ( additionalBuffer != null ) { bufs [ 1 ] = additionalBuffer ; totalLength += bufs [ 1 ] . remaining ( ) ; } if ( totalLength > 0 ) { long total = 0 ; long res = 0 ; do { res = next . write ( bufs , 0 , bufs . length ) ; total += res ; if ( res == 0 ) { return false ; } } while ( total < totalLength ) ; } additionalBuffer = null ; currentBuffer . getBuffer ( ) . clear ( ) ; state = state & ~ FLUSHING_BUFFER ; } return true ; } | The we are in the flushing state then we flush to the underlying stream otherwise just return true |
10,455 | private void deflateData ( boolean force ) throws IOException { boolean nextCreated = false ; try ( PooledByteBuffer arrayPooled = this . exchange . getConnection ( ) . getByteBufferPool ( ) . getArrayBackedPool ( ) . allocate ( ) ) { PooledByteBuffer pooled = this . currentBuffer ; final ByteBuffer outputBuffer = pooled . getBuffer ( ) ; final boolean shutdown = anyAreSet ( state , SHUTDOWN ) ; ByteBuffer buf = arrayPooled . getBuffer ( ) ; while ( force || ! deflater . needsInput ( ) || ( shutdown && ! deflater . finished ( ) ) ) { int count = deflater . deflate ( buf . array ( ) , buf . arrayOffset ( ) , buf . remaining ( ) , force ? Deflater . SYNC_FLUSH : Deflater . NO_FLUSH ) ; Connectors . updateResponseBytesSent ( exchange , count ) ; if ( count != 0 ) { int remaining = outputBuffer . remaining ( ) ; if ( remaining > count ) { outputBuffer . put ( buf . array ( ) , buf . arrayOffset ( ) , count ) ; } else { if ( remaining == count ) { outputBuffer . put ( buf . array ( ) , buf . arrayOffset ( ) , count ) ; } else { outputBuffer . put ( buf . array ( ) , buf . arrayOffset ( ) , remaining ) ; additionalBuffer = ByteBuffer . allocate ( count - remaining ) ; additionalBuffer . put ( buf . array ( ) , buf . arrayOffset ( ) + remaining , count - remaining ) ; additionalBuffer . flip ( ) ; } outputBuffer . flip ( ) ; this . state |= FLUSHING_BUFFER ; if ( next == null ) { nextCreated = true ; this . next = createNextChannel ( ) ; } if ( ! performFlushIfRequired ( ) ) { return ; } } } else { force = false ; } } } finally { if ( nextCreated ) { if ( anyAreSet ( state , WRITES_RESUMED ) ) { next . resumeWrites ( ) ; } } } } | Runs the current data through the deflater . As much as possible this will be buffered in the current output stream . |
10,456 | public void sendClose ( ) throws IOException { closeReason = "" ; closeCode = CloseMessage . NORMAL_CLOSURE ; StreamSinkFrameChannel closeChannel = send ( WebSocketFrameType . CLOSE ) ; closeChannel . shutdownWrites ( ) ; if ( ! closeChannel . flush ( ) ) { closeChannel . getWriteSetter ( ) . set ( ChannelListeners . flushingChannelListener ( null , new ChannelExceptionHandler < StreamSinkChannel > ( ) { public void handleException ( final StreamSinkChannel channel , final IOException exception ) { IoUtils . safeClose ( WebSocketChannel . this ) ; } } ) ) ; closeChannel . resumeWrites ( ) ; } } | Send a Close frame without a payload |
10,457 | public static void sendPingBlocking ( final ByteBuffer data , final WebSocketChannel wsChannel ) throws IOException { sendBlockingInternal ( data , WebSocketFrameType . PING , wsChannel ) ; } | Sends a complete ping message using blocking IO |
10,458 | public static void sendPingBlocking ( final PooledByteBuffer pooledData , final WebSocketChannel wsChannel ) throws IOException { sendBlockingInternal ( pooledData , WebSocketFrameType . PING , wsChannel ) ; } | Sends a complete ping message using blocking IO Automatically frees the pooled byte buffer when done . |
10,459 | public static void sendPongBlocking ( final ByteBuffer [ ] data , final WebSocketChannel wsChannel ) throws IOException { sendBlockingInternal ( mergeBuffers ( data ) , WebSocketFrameType . PONG , wsChannel ) ; } | Sends a complete pong message using blocking IO |
10,460 | public static void sendPongBlocking ( final PooledByteBuffer pooledData , final WebSocketChannel wsChannel ) throws IOException { sendBlockingInternal ( pooledData , WebSocketFrameType . PONG , wsChannel ) ; } | Sends a complete pong message using blocking IO Automatically frees the pooled byte buffer when done . |
10,461 | public static void sendBinaryBlocking ( final ByteBuffer data , final WebSocketChannel wsChannel ) throws IOException { sendBlockingInternal ( data , WebSocketFrameType . BINARY , wsChannel ) ; } | Sends a complete binary message using blocking IO |
10,462 | public static void sendBinaryBlocking ( final PooledByteBuffer pooledData , final WebSocketChannel wsChannel ) throws IOException { sendBlockingInternal ( pooledData , WebSocketFrameType . BINARY , wsChannel ) ; } | Sends a complete binary message using blocking IO Automatically frees the pooled byte buffer when done . |
10,463 | static < E > Node < E > newNode ( E item ) { Node < E > node = new Node < E > ( ) ; ITEM . set ( node , item ) ; return node ; } | Returns a new node holding item . Uses relaxed write because item can only be seen after piggy - backing publication via CAS . |
10,464 | private boolean bulkRemove ( Predicate < ? super E > filter ) { boolean removed = false ; for ( Node < E > p = first ( ) , succ ; p != null ; p = succ ) { succ = succ ( p ) ; final E item ; if ( ( item = p . item ) != null && filter . test ( item ) && ITEM . compareAndSet ( p , item , null ) ) { unlink ( p ) ; removed = true ; } } return removed ; } | Implementation of bulk remove methods . |
10,465 | public boolean pushResource ( final String path , final HttpString method , final HeaderMap requestHeaders , HttpHandler handler ) { return false ; } | Attempts to push a resource if this connection supports server push . Otherwise the request is ignored . |
10,466 | static void pingHost ( InetSocketAddress address , HttpServerExchange exchange , PingCallback callback , OptionMap options ) { final XnioIoThread thread = exchange . getIoThread ( ) ; final XnioWorker worker = thread . getWorker ( ) ; final HostPingTask r = new HostPingTask ( address , worker , callback , options ) ; scheduleCancelTask ( exchange . getIoThread ( ) , r , 5 , TimeUnit . SECONDS ) ; exchange . dispatch ( exchange . isInIoThread ( ) ? SameThreadExecutor . INSTANCE : thread , r ) ; } | Try to open a socket connection to given address . |
10,467 | static void pingHttpClient ( URI connection , PingCallback callback , HttpServerExchange exchange , UndertowClient client , XnioSsl xnioSsl , OptionMap options ) { final XnioIoThread thread = exchange . getIoThread ( ) ; final RequestExchangeListener exchangeListener = new RequestExchangeListener ( callback , NodeHealthChecker . NO_CHECK , true ) ; final Runnable r = new HttpClientPingTask ( connection , exchangeListener , thread , client , xnioSsl , exchange . getConnection ( ) . getByteBufferPool ( ) , options ) ; exchange . dispatch ( exchange . isInIoThread ( ) ? SameThreadExecutor . INSTANCE : thread , r ) ; scheduleCancelTask ( exchange . getIoThread ( ) , exchangeListener , 5 , TimeUnit . SECONDS ) ; } | Try to ping a server using the undertow client . |
10,468 | static void pingNode ( final Node node , final HttpServerExchange exchange , final PingCallback callback ) { if ( node == null ) { callback . failed ( ) ; return ; } final int timeout = node . getNodeConfig ( ) . getPing ( ) ; exchange . dispatch ( exchange . isInIoThread ( ) ? SameThreadExecutor . INSTANCE : exchange . getIoThread ( ) , new Runnable ( ) { public void run ( ) { node . getConnectionPool ( ) . connect ( null , exchange , new ProxyCallback < ProxyConnection > ( ) { public void completed ( final HttpServerExchange exchange , ProxyConnection result ) { final RequestExchangeListener exchangeListener = new RequestExchangeListener ( callback , NodeHealthChecker . NO_CHECK , false ) ; exchange . dispatch ( SameThreadExecutor . INSTANCE , new ConnectionPoolPingTask ( result , exchangeListener , node . getNodeConfig ( ) . getConnectionURI ( ) ) ) ; scheduleCancelTask ( exchange . getIoThread ( ) , exchangeListener , timeout , TimeUnit . SECONDS ) ; } public void failed ( HttpServerExchange exchange ) { callback . failed ( ) ; } public void queuedRequestFailed ( HttpServerExchange exchange ) { callback . failed ( ) ; } public void couldNotResolveBackend ( HttpServerExchange exchange ) { callback . failed ( ) ; } } , timeout , TimeUnit . SECONDS , false ) ; } } ) ; } | Try to ping a node using it s connection pool . |
10,469 | static void internalPingNode ( Node node , PingCallback callback , NodeHealthChecker healthChecker , XnioIoThread ioThread , ByteBufferPool bufferPool , UndertowClient client , XnioSsl xnioSsl , OptionMap options ) { final URI uri = node . getNodeConfig ( ) . getConnectionURI ( ) ; final long timeout = node . getNodeConfig ( ) . getPing ( ) ; final RequestExchangeListener exchangeListener = new RequestExchangeListener ( callback , healthChecker , true ) ; final HttpClientPingTask r = new HttpClientPingTask ( uri , exchangeListener , ioThread , client , xnioSsl , bufferPool , options ) ; scheduleCancelTask ( ioThread , exchangeListener , timeout , TimeUnit . SECONDS ) ; ioThread . execute ( r ) ; } | Internally ping a node . This should probably use the connections from the nodes pool if there are any available . |
10,470 | public static boolean isAbsoluteUrl ( String location ) { if ( location != null && location . length ( ) > 0 && location . contains ( ":" ) ) { try { URI uri = new URI ( location ) ; return uri . getScheme ( ) != null ; } catch ( URISyntaxException e ) { } } return false ; } | Test if provided location is an absolute URI or not . |
10,471 | private static void stateNotFound ( final CodeAttribute c , final TableSwitchBuilder builder ) { c . branchEnd ( builder . getDefaultBranchEnd ( ) . get ( ) ) ; c . newInstruction ( RuntimeException . class ) ; c . dup ( ) ; c . ldc ( "Invalid character" ) ; c . invokespecial ( RuntimeException . class . getName ( ) , "<init>" , "(Ljava/lang/String;)V" ) ; c . athrow ( ) ; } | Throws an exception when an invalid state is hit in a tableswitch |
10,472 | public static void decode ( ByteBuffer data , int length , StringBuilder target ) throws HpackException { assert data . remaining ( ) >= length ; int treePos = 0 ; boolean eosBits = true ; int eosCount = 0 ; for ( int i = 0 ; i < length ; ++ i ) { byte b = data . get ( ) ; int bitPos = 7 ; while ( bitPos >= 0 ) { int val = DECODING_TABLE [ treePos ] ; if ( ( ( 1 << bitPos ) & b ) == 0 ) { if ( ( val & LOW_TERMINAL_BIT ) == 0 ) { treePos = val & LOW_MASK ; eosBits = false ; eosCount = 0 ; } else { target . append ( ( char ) ( val & LOW_MASK ) ) ; treePos = 0 ; eosBits = true ; eosCount = 0 ; } } else { if ( ( val & HIGH_TERMINAL_BIT ) == 0 ) { treePos = ( val >> 16 ) & LOW_MASK ; if ( eosBits ) { eosCount ++ ; } } else { target . append ( ( char ) ( ( val >> 16 ) & LOW_MASK ) ) ; treePos = 0 ; eosCount = 0 ; eosBits = true ; } } bitPos -- ; } } if ( ! eosBits || eosCount > 7 ) { throw UndertowMessages . MESSAGES . huffmanEncodedHpackValueDidNotEndWithEOS ( ) ; } } | Decodes a huffman encoded string into the target StringBuilder . There must be enough space left in the buffer for this method to succeed . |
10,473 | public static boolean encode ( ByteBuffer buffer , String toEncode , boolean forceLowercase ) { if ( buffer . remaining ( ) <= toEncode . length ( ) ) { return false ; } int start = buffer . position ( ) ; int length = 0 ; for ( int i = 0 ; i < toEncode . length ( ) ; ++ i ) { byte c = ( byte ) toEncode . charAt ( i ) ; if ( forceLowercase ) { c = Hpack . toLower ( c ) ; } HuffmanCode code = HUFFMAN_CODES [ c ] ; length += code . length ; } int byteLength = length / 8 + ( length % 8 == 0 ? 0 : 1 ) ; buffer . put ( ( byte ) ( 1 << 7 ) ) ; Hpack . encodeInteger ( buffer , byteLength , 7 ) ; int bytePos = 0 ; byte currentBufferByte = 0 ; for ( int i = 0 ; i < toEncode . length ( ) ; ++ i ) { byte c = ( byte ) toEncode . charAt ( i ) ; if ( forceLowercase ) { c = Hpack . toLower ( c ) ; } HuffmanCode code = HUFFMAN_CODES [ c ] ; if ( code . length + bytePos <= 8 ) { currentBufferByte |= ( ( code . value & 0xFF ) << 8 - ( code . length + bytePos ) ) ; bytePos += code . length ; } else { int val = code . value ; int rem = code . length ; while ( rem > 0 ) { if ( ! buffer . hasRemaining ( ) ) { buffer . position ( start ) ; return false ; } int remainingInByte = 8 - bytePos ; if ( rem > remainingInByte ) { currentBufferByte |= ( val >> ( rem - remainingInByte ) ) ; } else { currentBufferByte |= ( val << ( remainingInByte - rem ) ) ; } if ( rem > remainingInByte ) { buffer . put ( currentBufferByte ) ; currentBufferByte = 0 ; bytePos = 0 ; } else { bytePos = rem ; } rem -= remainingInByte ; } } if ( bytePos == 8 ) { if ( ! buffer . hasRemaining ( ) ) { buffer . position ( start ) ; return false ; } buffer . put ( currentBufferByte ) ; currentBufferByte = 0 ; bytePos = 0 ; } if ( buffer . position ( ) - start > toEncode . length ( ) ) { buffer . position ( start ) ; return false ; } } if ( bytePos > 0 ) { if ( ! buffer . hasRemaining ( ) ) { buffer . position ( start ) ; return false ; } buffer . put ( ( byte ) ( currentBufferByte | ( ( 0xFF ) >> bytePos ) ) ) ; } return true ; } | Encodes the given string into the buffer . If there is not enough space in the buffer or the encoded version is bigger than the original it will return false and not modify the buffers position |
10,474 | private SymlinkResult getSymlinkBase ( final String base , final Path file ) throws IOException { int nameCount = file . getNameCount ( ) ; Path root = fileSystem . getPath ( base ) ; int rootCount = root . getNameCount ( ) ; Path f = file ; for ( int i = nameCount - 1 ; i >= 0 ; i -- ) { if ( Files . isSymbolicLink ( f ) ) { return new SymlinkResult ( i + 1 > rootCount , f ) ; } f = f . getParent ( ) ; } return null ; } | Returns true is some element of path inside base path is a symlink . |
10,475 | private boolean isSymlinkSafe ( final Path file ) throws IOException { String canonicalPath = file . toRealPath ( ) . toString ( ) ; for ( String safePath : this . safePaths ) { if ( safePath . length ( ) > 0 ) { if ( safePath . startsWith ( fileSystem . getSeparator ( ) ) ) { if ( safePath . length ( ) > 0 && canonicalPath . length ( ) >= safePath . length ( ) && canonicalPath . startsWith ( safePath ) ) { return true ; } } else { String absSafePath = base + fileSystem . getSeparator ( ) + safePath ; Path absSafePathFile = fileSystem . getPath ( absSafePath ) ; String canonicalSafePath = absSafePathFile . toRealPath ( ) . toString ( ) ; if ( canonicalSafePath . length ( ) > 0 && canonicalPath . length ( ) >= canonicalSafePath . length ( ) && canonicalPath . startsWith ( canonicalSafePath ) ) { return true ; } } } } return false ; } | Security check for followSymlinks feature . Only follows those symbolink links defined in safePaths . |
10,476 | protected PathResource getFileResource ( final Path file , final String path , final Path symlinkBase , String normalizedFile ) throws IOException { if ( this . caseSensitive ) { if ( symlinkBase != null ) { String relative = symlinkBase . relativize ( file . normalize ( ) ) . toString ( ) ; String fileResolved = file . toRealPath ( ) . toString ( ) ; String symlinkBaseResolved = symlinkBase . toRealPath ( ) . toString ( ) ; if ( ! fileResolved . startsWith ( symlinkBaseResolved ) ) { log . tracef ( "Rejected path resource %s from path resource manager with base %s, as the case did not match actual case of %s" , path , base , normalizedFile ) ; return null ; } String compare = fileResolved . substring ( symlinkBaseResolved . length ( ) ) ; if ( compare . startsWith ( fileSystem . getSeparator ( ) ) ) { compare = compare . substring ( fileSystem . getSeparator ( ) . length ( ) ) ; } if ( relative . startsWith ( fileSystem . getSeparator ( ) ) ) { relative = relative . substring ( fileSystem . getSeparator ( ) . length ( ) ) ; } if ( relative . equals ( compare ) ) { log . tracef ( "Found path resource %s from path resource manager with base %s" , path , base ) ; return new PathResource ( file , this , path , eTagFunction . generate ( file ) ) ; } log . tracef ( "Rejected path resource %s from path resource manager with base %s, as the case did not match actual case of %s" , path , base , normalizedFile ) ; return null ; } else if ( isFileSameCase ( file , normalizedFile ) ) { log . tracef ( "Found path resource %s from path resource manager with base %s" , path , base ) ; return new PathResource ( file , this , path , eTagFunction . generate ( file ) ) ; } else { log . tracef ( "Rejected path resource %s from path resource manager with base %s, as the case did not match actual case of %s" , path , base , normalizedFile ) ; return null ; } } else { log . tracef ( "Found path resource %s from path resource manager with base %s" , path , base ) ; return new PathResource ( file , this , path , eTagFunction . generate ( file ) ) ; } } | Apply security check for case insensitive file systems . |
10,477 | void resumeReadsInternal ( boolean wakeup ) { synchronized ( lock ) { boolean alreadyResumed = anyAreSet ( state , STATE_READS_RESUMED ) ; state |= STATE_READS_RESUMED ; if ( ! alreadyResumed || wakeup ) { if ( ! anyAreSet ( state , STATE_IN_LISTENER_LOOP ) ) { state |= STATE_IN_LISTENER_LOOP ; getFramedChannel ( ) . runInIoThread ( new Runnable ( ) { public void run ( ) { try { boolean moreData ; do { ChannelListener < ? super R > listener = getReadListener ( ) ; if ( listener == null || ! isReadResumed ( ) ) { return ; } ChannelListeners . invokeChannelListener ( ( R ) AbstractFramedStreamSourceChannel . this , listener ) ; moreData = ( frameDataRemaining > 0 && data != null ) || ! pendingFrameData . isEmpty ( ) || anyAreSet ( state , STATE_WAITNG_MINUS_ONE ) ; } while ( allAreSet ( state , STATE_READS_RESUMED ) && allAreClear ( state , STATE_CLOSED | STATE_STREAM_BROKEN ) && moreData ) ; } finally { state &= ~ STATE_IN_LISTENER_LOOP ; } } } ) ; } } } } | For this class there is no difference between a resume and a wakeup |
10,478 | protected void dataReady ( FrameHeaderData headerData , PooledByteBuffer frameData ) { if ( anyAreSet ( state , STATE_STREAM_BROKEN | STATE_CLOSED ) ) { frameData . close ( ) ; return ; } synchronized ( lock ) { boolean newData = pendingFrameData . isEmpty ( ) ; this . pendingFrameData . add ( new FrameData ( headerData , frameData ) ) ; if ( newData ) { if ( waiters > 0 ) { lock . notifyAll ( ) ; } } waitingForFrame = false ; } if ( anyAreSet ( state , STATE_READS_RESUMED ) ) { resumeReadsInternal ( true ) ; } if ( headerData != null ) { currentStreamSize += headerData . getFrameLength ( ) ; if ( maxStreamSize > 0 && currentStreamSize > maxStreamSize ) { handleStreamTooLarge ( ) ; } } } | Called when data has been read from the underlying channel . |
10,479 | protected void markStreamBroken ( ) { if ( anyAreSet ( state , STATE_STREAM_BROKEN ) ) { return ; } synchronized ( lock ) { state |= STATE_STREAM_BROKEN ; PooledByteBuffer data = this . data ; if ( data != null ) { try { data . close ( ) ; } catch ( Throwable e ) { } this . data = null ; } for ( FrameData frame : pendingFrameData ) { frame . frameData . close ( ) ; } pendingFrameData . clear ( ) ; if ( isReadResumed ( ) ) { resumeReadsInternal ( true ) ; } if ( waiters > 0 ) { lock . notifyAll ( ) ; } } } | Called when this stream is no longer valid . Reads from the stream will result in an exception . |
10,480 | public static int getMaxBufferSizeToSave ( final HttpServerExchange exchange ) { int maxSize = exchange . getConnection ( ) . getUndertowOptions ( ) . get ( UndertowOptions . MAX_BUFFERED_REQUEST_SIZE , UndertowOptions . DEFAULT_MAX_BUFFERED_REQUEST_SIZE ) ; return maxSize ; } | With added possibility to save data from buffer instead f from request body there has to be method which returns max allowed buffer size to save . |
10,481 | private void returnConnection ( final ConnectionHolder connectionHolder ) { ClientStatistics stats = connectionHolder . clientConnection . getStatistics ( ) ; this . requestCount . incrementAndGet ( ) ; if ( stats != null ) { this . read . addAndGet ( stats . getRead ( ) ) ; this . written . addAndGet ( stats . getWritten ( ) ) ; stats . reset ( ) ; } HostThreadData hostData = getData ( ) ; if ( closed ) { IoUtils . safeClose ( connectionHolder . clientConnection ) ; ConnectionHolder con = hostData . availableConnections . poll ( ) ; while ( con != null ) { IoUtils . safeClose ( con . clientConnection ) ; con = hostData . availableConnections . poll ( ) ; } redistributeQueued ( hostData ) ; return ; } final ClientConnection connection = connectionHolder . clientConnection ; if ( connection . isOpen ( ) && ! connection . isUpgraded ( ) ) { CallbackHolder callback = hostData . awaitingConnections . poll ( ) ; while ( callback != null && callback . isCancelled ( ) ) { callback = hostData . awaitingConnections . poll ( ) ; } if ( callback != null ) { if ( callback . getTimeoutKey ( ) != null ) { callback . getTimeoutKey ( ) . remove ( ) ; } connectionReady ( connectionHolder , callback . getCallback ( ) , callback . getExchange ( ) , false ) ; } else { final int cachedConnectionCount = hostData . availableConnections . size ( ) ; if ( cachedConnectionCount >= maxCachedConnections ) { final ConnectionHolder holder = hostData . availableConnections . poll ( ) ; if ( holder != null ) { IoUtils . safeClose ( holder . clientConnection ) ; } } hostData . availableConnections . add ( connectionHolder ) ; if ( timeToLive > 0 ) { final long currentTime = System . currentTimeMillis ( ) ; connectionHolder . timeout = currentTime + timeToLive ; if ( hostData . availableConnections . size ( ) > coreCachedConnections ) { if ( hostData . nextTimeout <= 0 ) { hostData . timeoutKey = WorkerUtils . executeAfter ( connection . getIoThread ( ) , hostData . timeoutTask , timeToLive , TimeUnit . MILLISECONDS ) ; hostData . nextTimeout = connectionHolder . timeout ; } } } } } else if ( connection . isOpen ( ) && connection . isUpgraded ( ) ) { connection . getCloseSetter ( ) . set ( null ) ; handleClosedConnection ( hostData , connectionHolder ) ; } } | Called when the IO thread has completed a successful request |
10,482 | private void scheduleFailedHostRetry ( final HttpServerExchange exchange ) { final int retry = connectionPoolManager . getProblemServerRetry ( ) ; if ( retry > 0 && ! connectionPoolManager . isAvailable ( ) ) { WorkerUtils . executeAfter ( exchange . getIoThread ( ) , new Runnable ( ) { public void run ( ) { if ( closed ) { return ; } UndertowLogger . PROXY_REQUEST_LOGGER . debugf ( "Attempting to reconnect to failed host %s" , getUri ( ) ) ; client . connect ( new ClientCallback < ClientConnection > ( ) { public void completed ( ClientConnection result ) { UndertowLogger . PROXY_REQUEST_LOGGER . debugf ( "Connected to previously failed host %s, returning to service" , getUri ( ) ) ; if ( connectionPoolManager . clearError ( ) ) { final ConnectionHolder connectionHolder = new ConnectionHolder ( result ) ; final HostThreadData data = getData ( ) ; result . getCloseSetter ( ) . set ( new ChannelListener < ClientConnection > ( ) { public void handleEvent ( ClientConnection channel ) { handleClosedConnection ( data , connectionHolder ) ; } } ) ; data . connections ++ ; returnConnection ( connectionHolder ) ; } else { scheduleFailedHostRetry ( exchange ) ; } } public void failed ( IOException e ) { UndertowLogger . PROXY_REQUEST_LOGGER . debugf ( "Failed to reconnect to failed host %s" , getUri ( ) ) ; connectionPoolManager . handleError ( ) ; scheduleFailedHostRetry ( exchange ) ; } } , bindAddress , getUri ( ) , exchange . getIoThread ( ) , ssl , exchange . getConnection ( ) . getByteBufferPool ( ) , options ) ; } } , retry , TimeUnit . SECONDS ) ; } } | If a host fails we periodically retry |
10,483 | private void timeoutConnections ( final long currentTime , final HostThreadData data ) { int idleConnections = data . availableConnections . size ( ) ; for ( ; ; ) { ConnectionHolder holder ; if ( idleConnections > 0 && idleConnections > coreCachedConnections && ( holder = data . availableConnections . peek ( ) ) != null ) { if ( ! holder . clientConnection . isOpen ( ) ) { idleConnections -- ; } else if ( currentTime >= holder . timeout ) { holder = data . availableConnections . poll ( ) ; IoUtils . safeClose ( holder . clientConnection ) ; idleConnections -- ; } else { if ( data . timeoutKey != null ) { data . timeoutKey . remove ( ) ; data . timeoutKey = null ; } final long remaining = holder . timeout - currentTime + 1 ; data . nextTimeout = holder . timeout ; data . timeoutKey = WorkerUtils . executeAfter ( holder . clientConnection . getIoThread ( ) , data . timeoutTask , remaining , TimeUnit . MILLISECONDS ) ; return ; } } else { if ( data . timeoutKey != null ) { data . timeoutKey . remove ( ) ; data . timeoutKey = null ; } data . nextTimeout = - 1 ; return ; } } } | Timeout idle connections which are above the soft max cached connections limit . |
10,484 | private HostThreadData getData ( ) { Thread thread = Thread . currentThread ( ) ; if ( ! ( thread instanceof XnioIoThread ) ) { throw UndertowMessages . MESSAGES . canOnlyBeCalledByIoThread ( ) ; } XnioIoThread ioThread = ( XnioIoThread ) thread ; HostThreadData data = hostThreadData . get ( ioThread ) ; if ( data != null ) { return data ; } data = new HostThreadData ( ) ; HostThreadData existing = hostThreadData . putIfAbsent ( ioThread , data ) ; if ( existing != null ) { return existing ; } return data ; } | Gets the host data for this thread |
10,485 | void closeCurrentConnections ( ) { final CountDownLatch latch = new CountDownLatch ( hostThreadData . size ( ) ) ; for ( final Map . Entry < XnioIoThread , HostThreadData > data : hostThreadData . entrySet ( ) ) { data . getKey ( ) . execute ( new Runnable ( ) { public void run ( ) { ConnectionHolder d = data . getValue ( ) . availableConnections . poll ( ) ; while ( d != null ) { IoUtils . safeClose ( d . clientConnection ) ; d = data . getValue ( ) . availableConnections . poll ( ) ; } data . getValue ( ) . connections = 0 ; latch . countDown ( ) ; } } ) ; } try { latch . await ( 10 , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } } | Should only be used for tests . |
10,486 | public FormDataParser createParser ( final HttpServerExchange exchange ) { FormDataParser existing = exchange . getAttachment ( ATTACHMENT_KEY ) ; if ( existing != null ) { return existing ; } for ( int i = 0 ; i < parserDefinitions . length ; ++ i ) { FormDataParser parser = parserDefinitions [ i ] . create ( exchange ) ; if ( parser != null ) { exchange . putAttachment ( ATTACHMENT_KEY , parser ) ; return parser ; } } return null ; } | Creates a form data parser for this request . If a parser has already been created for the request the existing parser will be returned rather than creating a new one . |
10,487 | protected void storeInitialLocation ( final HttpServerExchange exchange , byte [ ] bytes , int contentLength ) { if ( ! saveOriginalRequest ) { return ; } final ServletRequestContext servletRequestContext = exchange . getAttachment ( ServletRequestContext . ATTACHMENT_KEY ) ; HttpSessionImpl httpSession = servletRequestContext . getCurrentServletContext ( ) . getSession ( exchange , true ) ; Session session ; if ( System . getSecurityManager ( ) == null ) { session = httpSession . getSession ( ) ; } else { session = AccessController . doPrivileged ( new HttpSessionImpl . UnwrapSessionAction ( httpSession ) ) ; } SessionManager manager = session . getSessionManager ( ) ; if ( seenSessionManagers . add ( manager ) ) { manager . registerSessionListener ( LISTENER ) ; } session . setAttribute ( SESSION_KEY , RedirectBuilder . redirect ( exchange , exchange . getRelativePath ( ) ) ) ; if ( bytes == null ) { SavedRequest . trySaveRequest ( exchange ) ; } else { SavedRequest . trySaveRequest ( exchange , bytes , contentLength ) ; } } | This method doesn t save content of request but instead uses data from parameter . This should be used in case that data from request was already read and therefore it is not possible to save them . |
10,488 | public HttpServerExchange setRequestURI ( final String requestURI , boolean containsHost ) { this . requestURI = requestURI ; if ( containsHost ) { this . state |= FLAG_URI_CONTAINS_HOST ; } else { this . state &= ~ FLAG_URI_CONTAINS_HOST ; } return this ; } | Sets the request URI |
10,489 | public int getHostPort ( ) { String host = requestHeaders . getFirst ( Headers . HOST ) ; if ( host != null ) { final int colonIndex ; if ( host . startsWith ( "[" ) ) { colonIndex = host . indexOf ( ':' , host . indexOf ( ']' ) ) ; } else { colonIndex = host . indexOf ( ':' ) ; } if ( colonIndex != - 1 ) { try { return Integer . parseInt ( host . substring ( colonIndex + 1 ) ) ; } catch ( NumberFormatException ignore ) { } } if ( getRequestScheme ( ) . equals ( "https" ) ) { return 443 ; } else if ( getRequestScheme ( ) . equals ( "http" ) ) { return 80 ; } } return getDestinationAddress ( ) . getPort ( ) ; } | Return the port that this request was sent to . In general this will be the value of the Host header minus the host name . |
10,490 | void updateBytesSent ( long bytes ) { if ( Connectors . isEntityBodyAllowed ( this ) && ! getRequestMethod ( ) . equals ( Methods . HEAD ) ) { responseBytesSent += bytes ; } } | Updates the number of response bytes sent . Used when compression is in use |
10,491 | public HttpServerExchange setDispatchExecutor ( final Executor executor ) { if ( executor == null ) { dispatchExecutor = null ; } else { dispatchExecutor = executor ; } return this ; } | Sets the executor that is used for dispatch operations where no executor is specified . |
10,492 | public HttpServerExchange setResponseContentLength ( long length ) { if ( length == - 1 ) { responseHeaders . remove ( Headers . CONTENT_LENGTH ) ; } else { responseHeaders . put ( Headers . CONTENT_LENGTH , Long . toString ( length ) ) ; } return this ; } | Sets the response content length |
10,493 | public Map < String , Deque < String > > getQueryParameters ( ) { if ( queryParameters == null ) { queryParameters = new TreeMap < > ( ) ; } return queryParameters ; } | Returns a mutable map of query parameters . |
10,494 | public Map < String , Deque < String > > getPathParameters ( ) { if ( pathParameters == null ) { pathParameters = new TreeMap < > ( ) ; } return pathParameters ; } | Returns a mutable map of path parameters |
10,495 | public HttpServerExchange setResponseCookie ( final Cookie cookie ) { if ( getConnection ( ) . getUndertowOptions ( ) . get ( UndertowOptions . ENABLE_RFC6265_COOKIE_VALIDATION , UndertowOptions . DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION ) ) { if ( cookie . getValue ( ) != null && ! cookie . getValue ( ) . isEmpty ( ) ) { Rfc6265CookieSupport . validateCookieValue ( cookie . getValue ( ) ) ; } if ( cookie . getPath ( ) != null && ! cookie . getPath ( ) . isEmpty ( ) ) { Rfc6265CookieSupport . validatePath ( cookie . getPath ( ) ) ; } if ( cookie . getDomain ( ) != null && ! cookie . getDomain ( ) . isEmpty ( ) ) { Rfc6265CookieSupport . validateDomain ( cookie . getDomain ( ) ) ; } } if ( responseCookies == null ) { responseCookies = new TreeMap < > ( ) ; } responseCookies . put ( cookie . getName ( ) , cookie ) ; return this ; } | Sets a response cookie |
10,496 | public boolean isRequestComplete ( ) { PooledByteBuffer [ ] data = getAttachment ( BUFFERED_REQUEST_DATA ) ; if ( data != null ) { return false ; } return allAreSet ( state , FLAG_REQUEST_TERMINATED ) ; } | Returns true if all data has been read from the request or if there was not data . |
10,497 | void terminateRequest ( ) { int oldVal = state ; if ( allAreSet ( oldVal , FLAG_REQUEST_TERMINATED ) ) { return ; } if ( requestChannel != null ) { requestChannel . requestDone ( ) ; } this . state = oldVal | FLAG_REQUEST_TERMINATED ; if ( anyAreSet ( oldVal , FLAG_RESPONSE_TERMINATED ) ) { invokeExchangeCompleteListeners ( ) ; } } | Force the codec to treat the request as fully read . Should only be invoked by handlers which downgrade the socket or implement a transfer coding . |
10,498 | HttpServerExchange terminateResponse ( ) { int oldVal = state ; if ( allAreSet ( oldVal , FLAG_RESPONSE_TERMINATED ) ) { return this ; } if ( responseChannel != null ) { responseChannel . responseDone ( ) ; } this . state = oldVal | FLAG_RESPONSE_TERMINATED ; if ( anyAreSet ( oldVal , FLAG_REQUEST_TERMINATED ) ) { invokeExchangeCompleteListeners ( ) ; } return this ; } | Force the codec to treat the response as fully written . Should only be invoked by handlers which downgrade the socket or implement a transfer coding . |
10,499 | public HttpServerExchange setMaxEntitySize ( final long maxEntitySize ) { if ( ! isRequestChannelAvailable ( ) ) { throw UndertowMessages . MESSAGES . requestChannelAlreadyProvided ( ) ; } this . maxEntitySize = maxEntitySize ; connection . maxEntitySizeUpdated ( this ) ; return this ; } | Sets the max entity size for this exchange . This cannot be modified after the request channel has been obtained . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.