org.simpleframework.http.Request.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.simpleframework.http.Request.getValue方法的一些代码示例,展示了Request.getValue的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getValue方法的具体详情如下:
包路径:org.simpleframework.http.Request
类名称:Request
方法名:getValue

Request.getValue介绍

暂无

代码示例

代码示例来源:origin: jersey/jersey

private URI getBaseUri(final Request request) {
  try {
    final String hostHeader = request.getValue("Host");
    if (hostHeader != null) {
      final String scheme = request.isSecure() ? "https" : "http";
      return new URI(scheme + "://" + hostHeader + "/");
    } else {
      final Address address = request.getAddress();
      return new URI(address.getScheme(), null, address.getDomain(), address.getPort(), "/", null,
          null);
    }
  } catch (final URISyntaxException ex) {
    throw new IllegalArgumentException(ex);
  }
}

代码示例来源:origin: SonarSource/sonarqube

if (!"gzip".equals(req.getValue("Accept-Encoding"))) {
 throw new IllegalStateException("Should accept gzip");

代码示例来源:origin: jersey/jersey

@Override
public void handle(final Request request, final Response response) {
  final ResponseWriter responseWriter = new ResponseWriter(response, scheduler);
  final URI baseUri = getBaseUri(request);
  final URI requestUri = getRequestUri(request, baseUri);
  try {
    final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri,
        request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate());
    requestContext.setEntityStream(request.getInputStream());
    for (final String headerName : request.getNames()) {
      requestContext.headers(headerName, request.getValue(headerName));
    }
    requestContext.setWriter(responseWriter);
    requestContext.setRequestScopedInitializer(injectionManager -> {
      injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
      injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
    });
    appHandler.handle(requestContext);
  } catch (final Exception ex) {
    throw new RuntimeException(ex);
  } finally {
    if (!responseWriter.isSuspended()) {
      close(response);
    }
  }
}

代码示例来源:origin: miltonio/milton2

@Override
public String getRequestHeader(Header header) {
  return baseRequest.getValue(header.code);
}

代码示例来源:origin: CodeStory/fluent-http

@Override
public String header(String name) {
 return request.getValue(name);
}

代码示例来源:origin: lantunes/fixd

public String getHeaderValue(String name) {
  
  return request.getValue(name);
}

代码示例来源:origin: ngallagher/simpleframework

/**
* This can be used to get the value of the first message header
* that has the specified name. The value provided from this will
* be trimmed so there is no need to modify the value, also if 
* the header name specified refers to a comma seperated list of
* values the value returned is the first value in that list.  
* This returns null if theres no HTTP message header.
*
* @param name the HTTP message header to get the value from
*
* @return this returns the value that the HTTP message header
*/   
public String getValue(String name) {
 return request.getValue(name);
}

代码示例来源:origin: org.simpleframework/simple-http

/**
* This can be used to get the value of the first message header
* that has the specified name. The value provided from this will
* be trimmed so there is no need to modify the value, also if 
* the header name specified refers to a comma separated list of
* values the value returned is the first value in that list.  
* This returns null if theres no HTTP message header.
*
* @param name the HTTP message header to get the value from
* @param index if there are multiple values this selects one
*
* @return this returns the value that the HTTP message header
*/  
public String getValue(String name, int index) {
 return request.getValue(name, index);
}

代码示例来源:origin: org.simpleframework/simple

/**
* This can be used to get the value of the first message header
* that has the specified name. The value provided from this will
* be trimmed so there is no need to modify the value, also if 
* the header name specified refers to a comma seperated list of
* values the value returned is the first value in that list.  
* This returns null if theres no HTTP message header.
*
* @param name the HTTP message header to get the value from
*
* @return this returns the value that the HTTP message header
*/   
public String getValue(String name) {
 return request.getValue(name);
}

代码示例来源:origin: org.simpleframework/simple-http

/**
* This can be used to get the value of the first message header
* that has the specified name. The value provided from this will
* be trimmed so there is no need to modify the value, also if 
* the header name specified refers to a comma seperated list of
* values the value returned is the first value in that list.  
* This returns null if theres no HTTP message header.
*
* @param name the HTTP message header to get the value from
*
* @return this returns the value that the HTTP message header
*/   
public String getValue(String name) {
 return request.getValue(name);
}

代码示例来源:origin: org.simpleframework/simple

/**
* This can be used to get the value of the first message header
* that has the specified name. The value provided from this will
* be trimmed so there is no need to modify the value, also if 
* the header name specified refers to a comma separated list of
* values the value returned is the first value in that list.  
* This returns null if theres no HTTP message header.
*
* @param name the HTTP message header to get the value from
* @param index if there are multiple values this selects one
*
* @return this returns the value that the HTTP message header
*/  
public String getValue(String name, int index) {
 return request.getValue(name, index);
}

代码示例来源:origin: ngallagher/simpleframework

/**
* This can be used to get the value of the first message header
* that has the specified name. The value provided from this will
* be trimmed so there is no need to modify the value, also if 
* the header name specified refers to a comma separated list of
* values the value returned is the first value in that list.  
* This returns null if theres no HTTP message header.
*
* @param name the HTTP message header to get the value from
* @param index if there are multiple values this selects one
*
* @return this returns the value that the HTTP message header
*/  
public String getValue(String name, int index) {
 return request.getValue(name, index);
}

代码示例来源:origin: ngallagher/simpleframework

/**
* This is used to determine if the request is a valid WebSocket
* handshake of the correct version. This also checks to see if 
* the request contained the required handshake token.
* 
* @return this returns true if the request is a valid handshake
*/
private boolean isProtocol() {
 String protocol = request.getValue(SEC_WEBSOCKET_VERSION);
 String token = request.getValue(SEC_WEBSOCKET_KEY);
 
 if(token != null) {
   return version.equals(protocol);
 }
 return false;
}

代码示例来源:origin: restx/restx

@Override
public Optional<String> getHeader(String headerName) {
  return Optional.fromNullable(request.getValue(headerName));
}

代码示例来源:origin: org.simpleframework/simple-http

/**
* This is used to determine if the request is a valid WebSocket
* handshake of the correct version. This also checks to see if 
* the request contained the required handshake token.
* 
* @return this returns true if the request is a valid handshake
*/
private boolean isProtocol() {
 String protocol = request.getValue(SEC_WEBSOCKET_VERSION);
 String token = request.getValue(SEC_WEBSOCKET_KEY);
 
 if(token != null) {
   return version.equals(protocol);
 }
 return false;
}

代码示例来源:origin: io.restx/restx-server-simple

@Override
public Optional<String> getHeader(String headerName) {
  return Optional.fromNullable(request.getValue(headerName));
}

代码示例来源:origin: miltonio/milton2

public Map<String, String> getHeaders() {
  Map<String, String> headers = new HashMap<String, String>();
  for (String s : baseRequest.getNames()) {
    String val = baseRequest.getValue(s);
    headers.put(s, val);
  }
  return headers;
}

代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server

private InBoundHeaders getHeaders(Request request) {
  InBoundHeaders header = new InBoundHeaders();
  List<String> names = request.getNames();
  for (String name : names) {
    String value = request.getValue(name);
    header.add(name, value);
  }
  return header;
}

代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-simple-http

private URI getBaseUri(final Request request) {
  try {
    final String hostHeader = request.getValue("Host");
    if (hostHeader != null) {
      final String scheme = request.isSecure() ? "https" : "http";
      return new URI(scheme + "://" + hostHeader + "/");
    } else {
      final Address address = request.getAddress();
      return new URI(address.getScheme(), null, address.getDomain(), address.getPort(), "/", null,
          null);
    }
  } catch (final URISyntaxException ex) {
    throw new IllegalArgumentException(ex);
  }
}

代码示例来源:origin: org.restlet/org.restlet.ext.simple

/**
 * Returns the list of request headers.
 * 
 * @return The list of request headers.
 */
@Override
public Series<Parameter> getRequestHeaders() {
  final Series<Parameter> result = super.getRequestHeaders();
  if (!this.requestHeadersAdded) {
    final List<String> names = this.request.getNames();
    for (String name : names) {
      result.add(new Parameter(name, this.request.getValue(name)));
    }
    this.requestHeadersAdded = true;
  }
  return result;
}

相关文章