javax.servlet.http.HttpServletRequestWrapper.getInputStream()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(183)

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

HttpServletRequestWrapper.getInputStream介绍

暂无

代码示例

代码示例来源:origin: cloudfoundry/uaa

@Override
public ServletInputStream getInputStream() throws IOException {
  return super.getInputStream();
}

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

final ServletInputStream requestInputStream = super.getInputStream();
if (bufferedInputStream == null) {
  return requestInputStream;

代码示例来源:origin: perwendel/spark

private void cacheInputStream() throws IOException {
  cachedBytes = IOUtils.toByteArray(super.getInputStream());
}

代码示例来源:origin: perwendel/spark

@Override
public ServletInputStream getInputStream() throws IOException {
  HttpServletRequest request = (HttpServletRequest) super.getRequest();
  // disable stream cache for chunked transfer encoding
  String transferEncoding = request.getHeader("Transfer-Encoding");
  if ("chunked".equals(transferEncoding)) {
    return super.getInputStream();
  }
  // disable stream cache for multipart/form-data file upload
  // -> upload might be very large and might lead to out-of-memory error if we try to cache the bytes
  String contentType = request.getHeader("Content-Type");
  if (contentType != null && contentType.startsWith("multipart/form-data")) {
    return super.getInputStream();
  }
  if (cachedBytes == null) {
    cacheInputStream();
  }
  return new CachedServletInputStream();
}

代码示例来源:origin: prontera/spring-cloud-rest-tcc

/**
 * Get request body.
 *
 * @return Bytes with the request body contents.
 * @throws IOException In case stream reqding fails.
 */
public byte[] getRequestBody() throws IOException {
  final byte[] resultBytes;
  if (bufferFilled) {
    // 已经填入则直接返回
    resultBytes = Arrays.copyOf(requestBody, requestBody.length);
  } else {
    // 未填入则进行处理
    InputStream inputStream = super.getInputStream();
    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = inputStream.read(buffer)) != -1) {
      requestBody = Bytes.concat(this.requestBody, Arrays.copyOfRange(buffer, 0, bytesRead));
    }
    // 置标志位
    bufferFilled = true;
    resultBytes = Arrays.copyOf(requestBody, requestBody.length);
  }
  return resultBytes;
}

代码示例来源:origin: pig4cloud/pig

return super.getInputStream();
String json = IOUtils.toString(super.getInputStream(), "utf-8");
if (StringUtils.isBlank(json)) {
  return super.getInputStream();

代码示例来源:origin: 58code/Argo

/**
 * application/x-www-form-urlencoded
 *
 */
private void parsePostUrlEncoded() throws IOException {
  MultiMap<String> params = new MultiMap<String>();
  UrlEncoded.decodeTo(super.getInputStream(), params, "UTF-8", maxFormContentSize, maxFormKeys);
  forms = NullToEmptyMap.safeWrapper(params, getSafeParameter());
  
  Builder<String, Collection<String>> builder =  ImmutableMap.<String, Collection<String>>builder();
  
  if(queryStrings != null)
    builder.putAll(queryStrings);
  
  if(forms != null)
    builder.putAll(forms);
    this.params = builder.build();
}

代码示例来源:origin: 58code/Argo

private void parsePostMulti() throws IOException, ServletException {
  InputStream in = new BufferedInputStream(super.getInputStream());
  String content_type = super.getContentType();

代码示例来源:origin: ch.qos.logback/logback-access

@Override
public ServletInputStream getInputStream() throws IOException {
  if (!postedParametersMode) {
    return inStream;
  } else {
    return super.getInputStream();
  }
}

代码示例来源:origin: devefx/validator-web

@Override
  public ServletInputStream getInputStream() throws IOException {
    if (this.pushbackInputStream != null) {
      return this.pushbackInputStream;
    }
    return super.getInputStream();
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public ServletInputStream getInputStream() throws IOException
{
  ServletInputStream inputStream = super.getInputStream();
  return inputStream;
}

代码示例来源:origin: ESAPI/esapi-java-legacy

public ServletInputStream getInputStream() throws IOException {
  
  if ( isMultipart ) {
    return is;	
  } else {
    return super.getInputStream();
  }
  
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

/**
 * Cache the input stream in order to read it multiple times.
 *
 * @throws IOException
 */
private void cacheInputStream() throws IOException {
  cachedBytes = new ByteArrayOutputStream();
  IOUtils.copy(super.getInputStream(), cachedBytes);
}

代码示例来源:origin: org.apache.knox/gateway-server

public synchronized ServletInputStream getInputStream() throws IOException {
 if( log.isTraceEnabled() ) {
  if( input == null ) {
   input = new TraceInput( super.getInputStream() );
  }
  return input;
 } else {
  return super.getInputStream();
 }
}

代码示例来源:origin: org.jasig.portal/uPortal-rendering

@Override
public ServletInputStream getInputStream() throws IOException {
  this.checkState();
  return super.getInputStream();
}

代码示例来源:origin: com.github.edgar615/spring-boot-util-web

@Override
public ServletInputStream getInputStream() throws IOException {
 ByteArrayInputStream in = new ByteArrayInputStream(body.getBytes());
 return new ResettableServletInputStream(in, super.getInputStream());
}

代码示例来源:origin: com.atlassian.jira/jira-core

public ServletInputStream getInputStream() throws IOException
{
  if (capturingInputStream == null)
  {
    capturingInputStream = new CapturingInputStream(super.getInputStream());
  }
  return capturingInputStream;
}

代码示例来源:origin: zalando/logbook

@Override
public ServletInputStream getInputStream() throws IOException {
  return body == null ?
      super.getInputStream() :
      new ServletInputStreamAdapter(new ByteArrayInputStream(body));
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-server-support

@Override
public ServletInputStream getInputStream() throws IOException {
  this.is = new LoggingInputStream(super.getInputStream());
  return is;
}

代码示例来源:origin: apache/cxf

@Override
public ServletInputStream getInputStream() throws IOException {
  InputStream is = m.getContent(InputStream.class);
  if (is instanceof DelegatingInputStream) {
    is = ((DelegatingInputStream)is).getInputStream();
  }
  if (is instanceof ServletInputStream) {
    return (ServletInputStream)is;
  }
  return super.getInputStream();
}
@Override

相关文章

HttpServletRequestWrapper类方法