MCPcopy Index your code
hub / github.com/apache/tomcat / prepareRequest

Method prepareRequest

java/org/apache/coyote/ajp/AjpProcessor.java:646–877  ·  view source on GitHub ↗

After reading the request headers, we have to setup the request filters.

()

Source from the content-addressed store, hash-verified

644 * After reading the request headers, we have to setup the request filters.
645 */
646 @SuppressWarnings("deprecation")
647 private void prepareRequest() {
648
649 // Translate the HTTP method code to a String.
650 byte methodCode = requestHeaderMessage.getByte();
651 if (methodCode != Constants.SC_M_JK_STORED) {
652 String methodName = Constants.getMethodForCode(methodCode - 1);
653 request.setMethod(methodName);
654 }
655
656 requestHeaderMessage.getBytes(request.protocol());
657 requestHeaderMessage.getBytes(request.requestURI());
658
659 requestHeaderMessage.getBytes(request.remoteAddr());
660 requestHeaderMessage.getBytes(request.remoteHost());
661 requestHeaderMessage.getBytes(request.localName());
662 request.setLocalPort(requestHeaderMessage.getInt());
663
664 if (socketWrapper != null) {
665 request.peerAddr().setString(socketWrapper.getRemoteAddr());
666 }
667
668 boolean isSSL = requestHeaderMessage.getByte() != 0;
669 if (isSSL) {
670 request.scheme().setString("https");
671 }
672
673 // Decode headers
674 MimeHeaders headers = request.getMimeHeaders();
675
676 // Set this every time in case limit has been changed via JMX
677 headers.setLimit(protocol.getMaxHeaderCount());
678
679 boolean contentLengthSet = false;
680 int hCount = requestHeaderMessage.getInt();
681 for (int i = 0; i < hCount; i++) {
682 String hName;
683
684 // Header names are encoded as either an integer code starting
685 // with 0xA0, or as a normal string (in which case the first
686 // two bytes are the length).
687 int isc = requestHeaderMessage.peekInt();
688 int hId = isc & 0xFF;
689
690 MessageBytes vMB;
691 isc &= 0xFF00;
692 if (0xA000 == isc) {
693 requestHeaderMessage.getInt(); // To advance the read position
694 hName = Constants.getHeaderForCode(hId - 1);
695 vMB = headers.addValue(hName);
696 } else {
697 // reset hId -- if the header currently being read
698 // happens to be 7 or 8 bytes long, the code below
699 // will think it's the content-type header or the
700 // content-length header - SC_REQ_CONTENT_TYPE=7,
701 // SC_REQ_CONTENT_LENGTH=8 - leading to unexpected
702 // behaviour. see bug 5861 for more information.
703 hId = -1;

Callers 1

serviceMethod · 0.95

Calls 15

getMethodForCodeMethod · 0.95
setLimitMethod · 0.95
getHeaderForCodeMethod · 0.95
addValueMethod · 0.95
getByteChunkMethod · 0.95
getBufferMethod · 0.95
getLongMethod · 0.95
getBytesMethod · 0.95
equalsMethod · 0.95
startsWithIgnoreCaseMethod · 0.95
indexOfMethod · 0.95
setValueMethod · 0.95

Tested by

no test coverage detected