Only called in the slow case where slow means that the request headers were either fragmented across multiple TCP packets or too large to be processed in a single run. This method is also called to process trailing HTTP headers.
438176
function parserOnHeaders(headers, url) {
  // Once we exceeded headers limit - stop collecting them
  if (this.maxHeaderPairs <= 0 ||
      this._headers.length < this.maxHeaderPairs) {
    this._headers = this._headers.concat(headers);
  }
  this._url += url;
}
264535
protected HttpServletRequest processMultipart( HttpServletRequest request )
    {
        if ( ! "POST".equalsIgnoreCase( request.getMethod() ) ) return request;

        String contentType = request.getContentType();
        if ( contentType != null && contentType.startsWith( "multipart/form-data" ) )
        {
            PageFlowRequestWrapper pageFlowRequestWrapper = PageFlowRequestWrapper.get( request );

            //
            // We may have already gotten a multipart wrapper during process().  If so, use that.
            //
            MultipartRequestWrapper cachedWrapper = pageFlowRequestWrapper.getMultipartRequestWrapper();

            if ( cachedWrapper != null && cachedWrapper.getRequest() == request ) return cachedWrapper;

            try
            {
                //
                // First, pre-handle the multipart request.  This parses the stream and caches a single
                // MultipartRequestHandler in the outer request, so we can create new wrappers around it at will.
                //
                MultipartRequestUtils.preHandleMultipartRequest( request );
            }
            catch ( ServletException e )
            {
                LOG.error( "Could not parse multipart request.", e.getRootCause() );
                return request;
            }

            MultipartRequestWrapper ret = new RehydratedMultipartRequestWrapper( request );
            pageFlowRequestWrapper.setMultipartRequestWrapper( ret );
            return ret;
        }
        else
        {
            return request;
        }

    }
1315195
def process_request(self, request, client_address):
        
        if request is None or client_address is None:
            # request was never initialized, i.e. due to overload
            return 

        t = threading.Thread(target = self.process_request_thread,
                             args = (request, client_address))

        t.daemon = False

        with self._thread_guard:
            if self._close:
                # server is done. do not make more threads
                self.shutdown_request(request)
                return 

            if self._threads is None:
                self._threads = {}

            if len(self._threads) + 1 > MAX_RPC_THREADS:
                # overloaded
                log.warning("Too many outstanding requests ({})".format(len(self._threads)))
                self.shutdown_request(request)
                return

            t.start()

            self._threads[t.ident] = t

            if BLOCKSTACK_TEST:
                log.debug('{} active threads (added {})'.format(len(self._threads), t.ident))
758438
ClientStream returnStream() {
    synchronized (lock) {
      if (returnedStream == null) {
        // apply() has not been called, needs to buffer the requests.
        delayedStream = new DelayedStream();
        return returnedStream = delayedStream;
      } else {
        return returnedStream;
      }
    }
  }
1004813
private void processRequestHeaders(HttpAcceptSession acceptSession, HttpConnectSession connectSession) {
        boolean upgrade = processHopByHopHeaders(acceptSession, connectSession);

        // Add Connection: upgrade or Connection: close header
        if (upgrade) {
            connectSession.setWriteHeader(HEADER_CONNECTION, HEADER_UPGRADE);
        } else {
            ResourceAddress address = connectSession.getRemoteAddress();
            // If keep-alive is disabled, add Connection: close header
            if (!address.getOption(HttpResourceAddress.KEEP_ALIVE)) {
                connectSession.setWriteHeader(HEADER_CONNECTION, "close");
            }
        }

        // Add Via: 1.1 kaazing + uuid header
        connectSession.addWriteHeader(HEADER_VIA, viaHeader);

        // Add forwarded headers
        setupForwardedHeaders(acceptSession, connectSession);

    }
1258218
private static void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers)
            throws Exception {
        if (headers.isEndStream()) {
            ByteBuf content = ctx.alloc().buffer();
            content.writeBytes(RESPONSE_BYTES.duplicate());
            ByteBufUtil.writeAscii(content, " - via HTTP/2");
            sendResponse(ctx, content);
        }
    }
1082096
private function processHeaders()
    {
        if ($this->responseCode) {
            $this->setHeaderInPhp("HTTP/1.1 " . $this->getResponseCode() . " " . $this->getResponseMessage());
        }

        foreach ($this->headers as $type => $value) {
            $this->setHeaderInPhp($type . ": " . $value);
        }
    }
951626
private void throttledTransfer(MockResponse throttlePolicy, InputStream in, OutputStream out,
            long limit) throws IOException {
        byte[] buffer = new byte[1024];
        int bytesPerPeriod = throttlePolicy.getThrottleBytesPerPeriod();
        long delayMs = throttlePolicy.getThrottleUnit().toMillis(throttlePolicy.getThrottlePeriod());

        while (true) {
            for (int b = 0; b < bytesPerPeriod; ) {
                int toRead = (int) Math.min(Math.min(buffer.length, limit), bytesPerPeriod - b);
                int read = in.read(buffer, 0, toRead);
                if (read == -1) return;

                out.write(buffer, 0, read);
                out.flush();
                b += read;
                limit -= read;

                if (limit == 0) return;
            }

            try {
                if (delayMs != 0) Thread.sleep(delayMs);
            } catch (InterruptedException e) {
                throw new AssertionError();
            }
        }
    }
984038
protected void writeHeaders(HttpServletResponse response, Resource resource, long count) throws IOException
    {
        ResourceCache.ResourceMetaData metaData = _httpContext.getResourceMetaData(resource);

        response.setContentType(metaData.getMimeType());
        if (count != -1)
        {
            if (count == resource.length() && response instanceof ServletHttpResponse )
                response.setHeader(HttpFields.__ContentLength, metaData.getLength());
            else
                response.setContentLength((int) count);
        }

        response.setHeader(HttpFields.__LastModified, metaData.getLastModified());

        if (_acceptRanges)
            response.setHeader(HttpFields.__AcceptRanges, "bytes");
    }
135584
private synchronized void checkShutDownRunningProcesses() {
        smtpRequestsPhaser.arriveAndDeregister();
        LOGGER.trace("SMTP request threads left: {}", smtpRequestsPhaser.getUnarrivedParties());
        // if this thread is the last one finishing
        if (smtpRequestsPhaser.getUnarrivedParties() == 0) {
            LOGGER.trace("all threads have finished processing");
			//noinspection ConstantConditions
			if (needsAuthenticatedProxy() && proxyServer.isRunning() && !proxyServer.isStopping()) {
                LOGGER.trace("stopping proxy bridge...");
                proxyServer.stop();
            }
            // shutdown the threadpool, or else the Mailer will keep any JVM alive forever
            // executor is only available in async mode
            if (executor != null) {
                executor.shutdown();
            }
        }
    }
329278
void handleService(KNXnetIPHeader h, byte[] data, int offset)
		throws KNXFormatException
	{
		final int svc = h.getServiceType();
		if (h.getVersion() != KNXNETIP_VERSION_10)
			close(ConnectionCloseEvent.INTERNAL, "protocol version changed",
				LogLevel.ERROR, null);
		else if (svc == KNXnetIPHeader.ROUTING_IND) {
			final RoutingIndication ind = new RoutingIndication(data, offset,
				h.getTotalLength() - h.getStructLength());
			fireFrameReceived(ind.getCEMI());
		}
		else if (svc == KNXnetIPHeader.ROUTING_LOST_MSG) {
			final RoutingLostMessage lost = new RoutingLostMessage(data, offset);
			fireLostMessage(lost);
		}
		else
			logger.warn("received unknown frame (service type 0x"
				+ Integer.toHexString(svc) + ") - ignored");
	}
557445
public void processResetRequestAck(long dmeVersion, SendDispatcher sendDispatcher)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "processResetRequestAck", Long.valueOf(dmeVersion));

    // Only consider non-stale request acks
    if (dmeVersion >= _latestDMEVersion)
    {
      if (dmeVersion > _latestDMEVersion)
        _latestDMEVersion = dmeVersion;

      _slowedGetTOM.applyToEachEntry(new AddToEagerTOM(_slowedGetTOM, dmeVersion));
      sendDispatcher.sendResetRequestAckAck(dmeVersion);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "processResetRequestAck");
  }
774997
def _process_server_headers(
        self, key: Union[str, bytes], headers: httputil.HTTPHeaders
    ) -> None:
        
        assert headers["Upgrade"].lower() == "websocket"
        assert headers["Connection"].lower() == "upgrade"
        accept = self.compute_accept_value(key)
        assert headers["Sec-Websocket-Accept"] == accept

        extensions = self._parse_extensions_header(headers)
        for ext in extensions:
            if ext[0] == "permessage-deflate" and self._compression_options is not None:
                self._create_compressors("client", ext[1])
            else:
                raise ValueError("unsupported extension %r", ext)

        self.selected_subprotocol = headers.get("Sec-WebSocket-Protocol", None)
524580
public static void chainRequestDispatchers(RequestDispatcher[] dispatchers, HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException{
        for(int i=0; i<dispatchers.length-1; i++) {
            ChainedResponse chainedResp = new ChainedResponse(request, response);
            dispatchers[i].forward(request, chainedResp);
            request = chainedResp.getChainedRequest();
        }
        dispatchers[dispatchers.length-1].forward(request, response);
    }
1156517
def request_length(self):
        
        remainder = self.stop_at - self.offset
        return self.chunk_size if remainder > self.chunk_size else remainder
1091677
def multi_request(method, paths, body=nil, param=nil, header=nil)
      @multi = true

      # Response storage, if not already set
      if @responses.nil?
        @responses = []
      end

      # Handle one or many paths
      if paths.is_a? String or paths.is_a? URI
        paths = [paths]
      end

      # Handle (URI) objects
      paths = paths.map {|p| p.to_s }

      log.debug "Queueing multi-#{method} requests, concurrency: #{concurrency}, path(s): #{ paths.size == 1 ? paths[0]: paths.size }"

      paths.each do | path |

        multi_request = request(path, method.downcase.to_sym, body, param, header)
        multi_request.on_complete do | response |
          log.debug "Multi-#{method} [#{paths.size}]: "+log_message(response)
          @responses << response
        end
        hydra.queue(multi_request)
      end
      hydra
    end
238182
@Override
    protected boolean performRequest() {

        SocketChannel sc = null;
        boolean closeOnError = false;

        // If we were woken up because we have work to do, do it.
        Set<SelectionKey> keySet = this.selector.selectedKeys();
        Iterator<SelectionKey> keyIterator = keySet.iterator();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "performRequest - processing " + keySet.size() + " items");
        }

        while (keyIterator.hasNext()) {
            closeOnError = false;

            // If we get exceptions repeatedly, we may need to take a break for a number of reasons
            if (numExceptions >= 3100) {
                // if we don't recover after 290 more seconds, wait for 10 minutes
                if (pauseAccept()) {
                    resetExceptions(); // clear exceptions if we weren't interrupted
                }
                continue;
            } else if (numExceptions >= 200) {
                // if we get exceptions repeatedly, wait a tenth to give
                // other threads some time. It should take about 10 seconds for
                // us to get up to 200 exceptions (via trace analysis).
                if (numExceptions == 1500) {
                    FFDCFilter.processException(new Exception("TCP channel has received 1500 exceptions in a row on the accept selector"),
                                                getClass().getName(), "101", this);
                }
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ie) {
                    // ignore it
                }
            }

            // PK40415 - change audit handling of errors
            SelectionKey key = keyIterator.next();
            TCPPort endPoint = (TCPPort) key.attachment();
            TCPChannel tcpChannel = endPoint.getTCPChannel();

            try {
                // safe remove from set while iterating
                keyIterator.remove();

                // perform accept
                ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel();

                try {
                    sc = serverSocketChannel.accept();

                    // Configure all inbound channels to be non-blocking
                    if (sc != null) {
                        sc.configureBlocking(false);
                    }

                } catch (IOException ioe) {
                    incrementExceptions();
                    this.numAcceptIOExceptions++;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                        Tr.event(this, tc, "TCP Channel: " + tcpChannel.getExternalName() + " caught IOException doing accept: " + ioe + " total=" + numExceptions + " count="
                                           + numAcceptIOExceptions);
                    }
                    // Since we could be monitoring several serverSocketChannels, we need
                    // to continue processing even though we got an IOException on this
                    // serverSocketChannel.
                    continue;
                }

                // sometimes the accept can return null. This seems to happen when
                // there is a network problem, and we got notified it was ready to
                // accept, but when we went to do the accept we couldn't complete the accept. If
                // this happens, just skip this and go on
                if (sc == null) {
                    incrementExceptions();
                    this.numAcceptNulls++;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                        Tr.event(this, tc, "TCP Channel: " + tcpChannel.getExternalName() + " accept() returned null, total=" + numExceptions + " count=" + numAcceptNulls);
                    }
                    continue;
                }

                Socket socket = sc.socket();
                if (!testSocket(sc)) {
                    continue;
                }
                closeOnError = true;

                if (!tcpChannel.verifyConnection(socket)) {
                    closeSocketChannel(sc);

                    // if we made it this far, then the accept worked without exceptions
                    if (0 < this.numExceptions) {
                        resetExceptions();
                    }
                    continue;
                }

                SocketIOChannel ioSocket = null;
                try {
                    ioSocket = tcpChannel.createInboundSocketIOChannel(sc);
                } catch (IOException ioe) {
                    // no FFDC required
                    incrementExceptions();
                    this.numConfigureIOExceptions++;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                        Tr.event(this, tc, "IOException caught while configuring socket: " + ioe + ", total=" + numExceptions + " count=" + numConfigureIOExceptions);
                    }
                    closeSocketChannel(sc);
                    continue;
                }
                endPoint.processNewConnection(ioSocket);

            } catch (CancelledKeyException cke) {
                // no FFDC required
                // Should only get this if the socket was closed. Therefore
                // log error and continue processing
                incrementExceptions();
                this.numCancelledKeys++;
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(this, tc, "Cancelled key exception found, cke=" + cke + " total=" + numExceptions + " count=" + numCancelledKeys);
                }
                continue;
            } catch (Throwable t) {
                // don't leak sockets if we can't proceed after the accept
                if (closeOnError) {
                    closeSocketChannel(sc);
                }
                // the catcher of the RTE will do the FFDC
                throw new RuntimeException(t);
            }

            // if we made it this far, then the accept worked without exceptions
            if (0 < this.numExceptions) {
                resetExceptions();
            }
        } // end-while
        return false;
    }