本文整理了Java中org.simpleframework.http.Request.getInputStream
方法的一些代码示例,展示了Request.getInputStream
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getInputStream
方法的具体详情如下:
包路径:org.simpleframework.http.Request
类名称:Request
方法名:getInputStream
[英]This is used to read the content body. The specifics of the data that is read from this InputStream
can be determined by the getContentLength
method. If the data sent by the client is chunked then it is decoded, see RFC 2616 section 3.6. Also multipart data is available as Part
objects however the raw content of the multipart body is still available.
[中]这用于阅读内容正文。从InputStream
读取的数据的细节可以通过getContentLength
方法确定。如果对客户端发送的数据进行分块,则对其进行解码,请参阅RFC 2616第3.6节。多部分数据也可以作为Part
对象使用,但是多部分正文的原始内容仍然可用。
代码示例来源: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: lantunes/fixd
public InputStream getBodyAsStream() throws IOException {
return request.getInputStream();
}
代码示例来源:origin: org.restlet/org.restlet.ext.simple
@Override
public InputStream getRequestEntityStream(long size) {
try {
return this.request.getInputStream();
} catch (Exception ex) {
return null;
}
}
代码示例来源:origin: CodeStory/fluent-http
@Override
public InputStream inputStream() throws IOException {
return request.getInputStream();
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This is used to read the content body. The specifics of the data
* that is read from this <code>InputStream</code> can be determined
* by the <code>getContentLength</code> method. If the data sent by
* the client is chunked then it is decoded, see RFC 2616 section
* 3.6. Also multipart data is available as <code>Part</code> objects
* however the raw content of the multipart body is still available.
*
* @exception Exception signifies that there is an I/O problem
*
* @return returns the input stream containing the message body
*/
public InputStream getInputStream() throws IOException {
return request.getInputStream();
}
代码示例来源:origin: org.simpleframework/simple
/**
* This is used to read the content body. The specifics of the data
* that is read from this <code>InputStream</code> can be determined
* by the <code>getContentLength</code> method. If the data sent by
* the client is chunked then it is decoded, see RFC 2616 section
* 3.6. Also multipart data is available as <code>Part</code> objects
* however the raw content of the multipart body is still available.
*
* @exception Exception signifies that there is an I/O problem
*
* @return returns the input stream containing the message body
*/
public InputStream getInputStream() throws IOException {
return request.getInputStream();
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This is used to read the content body. The specifics of the data
* that is read from this <code>InputStream</code> can be determined
* by the <code>getContentLength</code> method. If the data sent by
* the client is chunked then it is decoded, see RFC 2616 section
* 3.6. Also multipart data is available as <code>Part</code> objects
* however the raw content of the multipart body is still available.
*
* @exception Exception signifies that there is an I/O problem
*
* @return returns the input stream containing the message body
*/
public InputStream getInputStream() throws IOException {
return request.getInputStream();
}
代码示例来源:origin: miltonio/milton2
@Override
public InputStream getInputStream() throws IOException {
try {
return baseRequest.getInputStream();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: restx/restx
@Override
public InputStream getContentStream() throws IOException {
/*
maybe we could do this buffering only in dev mode?
It is used to be able to read data again in case of json processing error.
*/
if (bufferedInputStream == null) {
bufferedInputStream = new BufferedInputStream(request.getInputStream()) {
@Override
public void close() throws IOException {
// NO OP, see #closeContentStream
}
};
bufferedInputStream.mark(10 * 1024);
}
return bufferedInputStream;
}
代码示例来源:origin: io.restx/restx-server-simple
@Override
public InputStream getContentStream() throws IOException {
/*
maybe we could do this buffering only in dev mode?
It is used to be able to read data again in case of json processing error.
*/
if (bufferedInputStream == null) {
bufferedInputStream = new BufferedInputStream(request.getInputStream()) {
@Override
public void close() throws IOException {
// NO OP, see #closeContentStream
}
};
bufferedInputStream.mark(10 * 1024);
}
return bufferedInputStream;
}
代码示例来源:origin: lantunes/fixd
public byte[] getBody() {
try {
return RequestUtils.readBody(request.getInputStream());
} catch (IOException e) {
throw new RuntimeException("error getting body", e);
}
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server
public void handle(Request request, Response response) {
WebApplication target = application;
final URI baseUri = getBaseUri(request);
final URI requestUri = baseUri.resolve(request.getTarget());
try {
final ContainerRequest cRequest = new ContainerRequest(
target,
request.getMethod(),
baseUri,
requestUri,
getHeaders(request),
request.getInputStream());
target.handleRequest(cRequest, new Writer(request, response));
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
close(response);
}
}
代码示例来源:origin: kristofa/mock-http-server
public static FullHttpRequest convert(final Request request) {
byte[] data = null;
try {
final InputStream inputStream = request.getInputStream();
try {
data = IOUtils.toByteArray(inputStream);
} finally {
inputStream.close();
}
} catch (final IOException e) {
LOGGER.error("IOException when getting request content.", e);
}
final FullHttpRequestImpl httpRequest = new FullHttpRequestImpl();
httpRequest.domain(request.getAddress().getDomain());
httpRequest.port(request.getAddress().getPort());
httpRequest.method(Method.valueOf(request.getMethod()));
httpRequest.path(request.getPath().getPath());
if (data.length > 0) {
httpRequest.content(data);
}
for (final String headerField : request.getNames()) {
for (final String headerFieldValue : request.getValues(headerField)) {
httpRequest.httpMessageHeader(headerField, headerFieldValue);
}
}
for (final Entry<String, String> entry : request.getQuery().entrySet()) {
httpRequest.queryParameter(entry.getKey(), entry.getValue());
}
return httpRequest;
}
代码示例来源:origin: org.kie.remote/kie-remote-client
public void handle( Request req, Response resp ) {
try {
PrintStream out = resp.getPrintStream(1024);
String address = req.getAddress().toString();
if( address.equals(DEFAULT_ENPOINT) ) {
String content = readInputStreamAsString(req.getInputStream());
JaxbCommandsRequest cmdsReq = (JaxbCommandsRequest) jaxbSerializationProvider.deserialize(content);
String [] headerNames = {
TEST_HEADER_NAME,
ANOTHER_TEST_HEADER_NAME,
NOT_SENT_HEADER_NAME
};
List<String> headerValues = new ArrayList<String>();
for( String headerName : headerNames ) {
String headerVal = req.getValue(headerName);
if( headerVal != null ) {
headerValues.add(headerVal);
}
}
String output = handleJaxbCommandsRequest(cmdsReq, headerValues);
resp.setCode(HttpURLConnection.HTTP_OK);
out.print(output);
} else {
resp.setCode(HttpURLConnection.HTTP_BAD_REQUEST);
}
out.close();
} catch( Exception e ) {
e.printStackTrace();
}
}
代码示例来源:origin: org.kie.remote/kie-remote-client
req.getInputStream().close();
req.getChannel().close();
} catch( IOException e ) {
代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-simple-http
@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);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!