List of usage examples for io.netty.util AsciiString byteAt
public byte byteAt(int index)
From source file:com.linecorp.armeria.server.http.jetty.JettyService.java
License:Apache License
private static MetaData.Request toRequestMetadata(ServiceRequestContext ctx, AggregatedHttpMessage aReq) { // Construct the HttpURI final StringBuilder uriBuf = new StringBuilder(); final HttpHeaders aHeaders = aReq.headers(); uriBuf.append(ctx.sessionProtocol().isTls() ? "https" : "http"); uriBuf.append("://"); uriBuf.append(aHeaders.authority()); uriBuf.append(aHeaders.path());// w w w . j ava 2s . c o m final HttpURI uri = new HttpURI(uriBuf.toString()); final String encoded = PATH_SPLITTER.splitToList(ctx.mappedPath()).stream() .map(UrlEscapers.urlPathSegmentEscaper()::escape).collect(Collectors.joining("/")); uri.setPath(encoded); // Convert HttpHeaders to HttpFields final HttpFields jHeaders = new HttpFields(aHeaders.size()); aHeaders.forEach(e -> { final AsciiString key = e.getKey(); if (!key.isEmpty() && key.byteAt(0) != ':') { jHeaders.add(key.toString(), e.getValue()); } }); return new MetaData.Request(aHeaders.method().name(), uri, HttpVersion.HTTP_1_1, jHeaders, aReq.content().length()); }
From source file:com.linecorp.armeria.server.http.tomcat.TomcatService.java
License:Apache License
private static void convertHeaders(HttpHeaders headers, MimeHeaders cHeaders) { if (headers.isEmpty()) { return;//w ww .jav a 2 s . c o m } for (Entry<AsciiString, String> e : headers) { final AsciiString k = e.getKey(); final String v = e.getValue(); if (k.isEmpty() || k.byteAt(0) == ':') { continue; } final MessageBytes cValue = cHeaders.addValue(k.array(), k.arrayOffset(), k.length()); final byte[] valueBytes = v.getBytes(StandardCharsets.US_ASCII); cValue.setBytes(valueBytes, 0, valueBytes.length); } }
From source file:com.linecorp.armeria.server.jetty.JettyService.java
License:Apache License
private static MetaData.Request toRequestMetadata(ServiceRequestContext ctx, AggregatedHttpMessage aReq) { // Construct the HttpURI final StringBuilder uriBuf = new StringBuilder(); final HttpHeaders aHeaders = aReq.headers(); uriBuf.append(ctx.sessionProtocol().isTls() ? "https" : "http"); uriBuf.append("://"); uriBuf.append(aHeaders.authority()); uriBuf.append(aHeaders.path());// ww w .ja va 2s.c o m final HttpURI uri = new HttpURI(uriBuf.toString()); uri.setPath(ctx.mappedPath()); // Convert HttpHeaders to HttpFields final HttpFields jHeaders = new HttpFields(aHeaders.size()); aHeaders.forEach(e -> { final AsciiString key = e.getKey(); if (!key.isEmpty() && key.byteAt(0) != ':') { jHeaders.add(key.toString(), e.getValue()); } }); return new MetaData.Request(aHeaders.method().name(), uri, HttpVersion.HTTP_1_1, jHeaders, aReq.content().length()); }