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' ) { b... | 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 ( ... | 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 , advertiseCo... | 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 ( ... | 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 . app... | 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 serverHelloLen... | 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 = exchan... | 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 . ... | 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 ( ... | 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 r... | 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 )... | 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 ... | 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 ; ... | 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 = ( HeaderValue... | 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 = ( He... | 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 ( HeaderVa... | 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_PO... | 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 ... | 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... | 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 ( ) ; dateFor... | 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 i... |
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 ... | 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 ContinueR... | 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 ... | 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 ] ) ... | 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 ( headerFi... | 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_... | 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 ... | 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 = toBeConve... | 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 . D... | 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 . leng... | 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 ( additional... | 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 = pool... | 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 . f... | 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 ... | 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 ) ; s... | 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 , NodeHealt... | 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 ... | 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 . getNodeCo... | 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 ( ) , ... | 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 v... | 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 ) ... | 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 ( ... | 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 && canonica... | 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 ... | 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 ( ) . r... | 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 ( headerDat... | 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 : pendi... | 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 . getWrit... | 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 ( close... | 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 ( ) ) != nu... | 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 != n... | 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 . getValu... | 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... | 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 = servletReques... | 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 { retur... | 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 ( ) ... | 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 ) ) { invokeExchangeCompleteListen... | 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 ) ) { invo... | 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.