@Nullable private static String toHeaderValue(MessageBytes value) { switch (value.getType()) { case MessageBytes.T_BYTES: { final ByteChunk chunk = value.getByteChunk(); return new String(chunk.getBuffer(), chunk.getOffset(), chunk.getLength(), StandardCharsets.US_ASCII); } case MessageBytes.T_CHARS: { final CharChunk chunk = value.getCharChunk(); return new String(chunk.getBuffer(), chunk.getOffset(), chunk.getLength()); } case MessageBytes.T_STR: { return value.getString(); } } return null; } }
@Nullable private static AsciiString toHeaderName(MessageBytes value) { switch (value.getType()) { case MessageBytes.T_BYTES: { final ByteChunk chunk = value.getByteChunk(); return new AsciiString(chunk.getBuffer(), chunk.getOffset(), chunk.getLength(), true); } case MessageBytes.T_CHARS: { final CharChunk chunk = value.getCharChunk(); return new AsciiString(chunk.getBuffer(), chunk.getOffset(), chunk.getLength()); } case MessageBytes.T_STR: { return HttpHeaderNames.of(value.getString()); } } return null; }
/** * Get the canonical request uri from the request mapping data requestPath * @param request * @return the request URI path */ static String requestURI(Request request) { String uri = request.getMappingData().requestPath.getString(); if (uri == null || uri.equals("/")) { uri = ""; } return uri; }
private void populateRequestMetadata(RequestMap metadata, Request req) { MimeHeaders headers = req.getMimeHeaders(); Enumeration nameEnum = headers.names(); while (nameEnum.hasMoreElements()) { Object nameObj = nameEnum.nextElement(); if (nameObj instanceof String) { Object valueObj = headers.getHeader((String) nameObj); metadata.put(nameObj, valueObj); } } metadata.put(HTTPMetadataConstants.METHODTYPE, req.method().getString()); metadata.put(HTTPMetadataConstants.PATH, req.requestURI().getString()); metadata.put(HTTPMetadataConstants.HTTPVERSION, req.protocol().getString()); }
if (value.indexOf(originalCookie.getName()) >= 0) { if (originalCookie.getDomain() == null) { StringBuilder builder = new StringBuilder(value.getString()).append("; Domain=").append(domainToSet); value.setString(builder.toString()); } else { String newDomain = value.getString().replaceAll("Domain=[A-Za-z0-9.-]*", "Domain=" + domainToSet); value.setString(newDomain);
forwardedHost = forwardedHost.substring(0, colonIndex); originalServerName = serverNameMB.getString(); serverNameMB.setString(forwardedHost);
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
/** Copy the src into this MessageBytes, allocating more space if * needed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } }
final void push(Request request) throws IOException { // Can only push when supported and from a peer initiated stream if (!isPushSupported() || getIdentifier().intValue() % 2 == 0) { return; } // Set the special HTTP/2 headers request.getMimeHeaders().addValue(":method").duplicate(request.method()); request.getMimeHeaders().addValue(":scheme").duplicate(request.scheme()); StringBuilder path = new StringBuilder(request.requestURI().toString()); if (!request.queryString().isNull()) { path.append('?'); path.append(request.queryString().toString()); } request.getMimeHeaders().addValue(":path").setString(path.toString()); // Authority needs to include the port only if a non-standard port is // being used. if (!(request.scheme().equals("http") && request.getServerPort() == 80) && !(request.scheme().equals("https") && request.getServerPort() == 443)) { request.getMimeHeaders().addValue(":authority").setString( request.serverName().getString() + ":" + request.getServerPort()); } else { request.getMimeHeaders().addValue(":authority").duplicate(request.serverName()); } push(handler, request, this); }
/** * Copy the src into this MessageBytes, allocating more space if needed. * @param src The source * @throws IOException Writing overflow data to the output channel failed */ public void duplicate( MessageBytes src ) throws IOException { switch( src.getType() ) { case MessageBytes.T_BYTES: type=T_BYTES; ByteChunk bc=src.getByteChunk(); byteC.allocate( 2 * bc.getLength(), -1 ); byteC.append( bc ); break; case MessageBytes.T_CHARS: type=T_CHARS; CharChunk cc=src.getCharChunk(); charC.allocate( 2 * cc.getLength(), -1 ); charC.append( cc ); break; case MessageBytes.T_STR: type=T_STR; String sc=src.getString(); this.setString( sc ); break; } setCharset(src.getCharset()); }
/** Convert a message bytes chars to bytes */ public final void convert(MessageBytes mb ) throws IOException { int type=mb.getType(); if( type==MessageBytes.T_BYTES ) return; ByteChunk orig=bb; setByteChunk( mb.getByteChunk()); bb.recycle(); bb.allocate( 32, -1 ); if( type==MessageBytes.T_STR ) { convert( mb.getString() ); // System.out.println("XXX Converting " + mb.getString() ); } else if( type==MessageBytes.T_CHARS ) { CharChunk charC=mb.getCharChunk(); convert( charC.getBuffer(), charC.getOffset(), charC.getLength()); //System.out.println("XXX Converting " + mb.getCharChunk() ); } else { if (log.isDebugEnabled()) log.debug("XXX unknowon type " + type ); } flushBuffer(); //System.out.println("C2B: XXX " + bb.getBuffer() + bb.getLength()); setByteChunk(orig); }
/** Convert a message bytes chars to bytes */ public final void convert(MessageBytes mb ) throws IOException { int type=mb.getType(); if( type==MessageBytes.T_BYTES ) return; ByteChunk orig=bb; setByteChunk( mb.getByteChunk()); bb.recycle(); bb.allocate( 32, -1 ); if( type==MessageBytes.T_STR ) { convert( mb.getString() ); // System.out.println("XXX Converting " + mb.getString() ); } else if( type==MessageBytes.T_CHARS ) { CharChunk charC=mb.getCharChunk(); convert( charC.getBuffer(), charC.getOffset(), charC.getLength()); //System.out.println("XXX Converting " + mb.getCharChunk() ); } else { if (log.isDebugEnabled()) log.debug("XXX unknowon type " + type ); } flushBuffer(); //System.out.println("C2B: XXX " + bb.getBuffer() + bb.getLength()); setByteChunk(orig); }
vary.getString() + ",Accept-Encoding");