private static HttpHeaders convertResponse(Response coyoteRes) { final HttpHeaders headers = HttpHeaders.of(HttpStatus.valueOf(coyoteRes.getStatus())); final String contentType = coyoteRes.getContentType(); if (contentType != null && !contentType.isEmpty()) { headers.set(HttpHeaderNames.CONTENT_TYPE, contentType); } final long contentLength = coyoteRes.getBytesWritten(true); // 'true' will trigger flush. final String method = coyoteRes.getRequest().method().toString(); if (!"HEAD".equals(method)) { headers.setLong(HttpHeaderNames.CONTENT_LENGTH, contentLength); } final MimeHeaders cHeaders = coyoteRes.getMimeHeaders(); final int numHeaders = cHeaders.size(); for (int i = 0; i < numHeaders; i++) { final AsciiString name = toHeaderName(cHeaders.getName(i)); if (name == null) { continue; } final String value = toHeaderValue(cHeaders.getValue(i)); if (value == null) { continue; } headers.add(name.toLowerCase(), value); } return headers; }
/** * @return the path information associated with this Request. */ @Override public String getPathInfo() { return mappingData.pathInfo.toString(); }
/** * @return the portion of the request URI used to select the servlet * that will process this request. */ @Override public String getServletPath() { return mappingData.wrapperPath.toString(); }
/** * Get the decoded request URI. * * @return the URL decoded request URI */ public String getDecodedRequestURI() { return coyoteRequest.decodedURI().toString(); }
/** * @return the HTTP request method used in this Request. */ @Override public String getMethod() { return coyoteRequest.method().toString(); }
/** * @return the request URI for this request. */ @Override public String getRequestURI() { return coyoteRequest.requestURI().toString(); }
@Override public Object get(Request request, String name) { return (request.requestDispatcherPath == null) ? request .getRequestPathMB().toString() : request.requestDispatcherPath.toString(); }
/** * @return the server name responding to this Request. */ @Override public String getServerName() { return coyoteRequest.serverName().toString(); }
/** * @return the query string associated with this request. */ @Override public String getQueryString() { return coyoteRequest.queryString().toString(); }
/** * @return the protocol and version used to make this Request. */ @Override public String getProtocol() { return coyoteRequest.protocol().toString(); }
/** * @return the scheme used to make this Request. */ @Override public String getScheme() { return coyoteRequest.scheme().toString(); }
/** * Return the server name responding to this Request. */ @Override public String getServerName() { return coyoteRequest.serverName().toString(); }
@Override public Object get(Request request, String name) { return (request.requestDispatcherPath == null) ? request .getRequestPathMB().toString() : request.requestDispatcherPath.toString(); }
/** * Return the server name responding to this Request. */ public String getServerName() { return (coyoteRequest.serverName().toString()); }
/** * Return the HTTP request method used in this Request. */ public String getMethod() { return coyoteRequest.method().toString(); }
/** * Return the request URI for this request. */ public String getRequestURI() { return coyoteRequest.requestURI().toString(); }
/** Do a char->byte conversion. */ public void toBytes() { if( ! byteC.isNull() ) { type=T_BYTES; return; } toString(); type=T_BYTES; byte bb[] = strValue.getBytes(StandardCharsets.ISO_8859_1); byteC.setBytes(bb, 0, bb.length); }
/** * @return the remote IP address making this Request. */ @Override public String getRemoteAddr() { if (remoteAddr == null) { coyoteRequest.action (ActionCode.REQ_HOST_ADDR_ATTRIBUTE, coyoteRequest); remoteAddr = coyoteRequest.remoteAddr().toString(); } return remoteAddr; }
/** * Returns the host name of the Internet Protocol (IP) interface on * which the request was received. */ public String getLocalName(){ if (localName == null) { coyoteRequest.action (ActionCode.ACTION_REQ_LOCAL_NAME_ATTRIBUTE, coyoteRequest); localName = coyoteRequest.localName().toString(); } return localName; }
@Override public Collection<String> getHeaderNames() { MimeHeaders headers = getCoyoteResponse().getMimeHeaders(); int n = headers.size(); List<String> result = new ArrayList<>(n); for (int i = 0; i < n; i++) { result.add(headers.getName(i).toString()); } return result; }