本文整理汇总了Java中io.netty.handler.codec.http.multipart.DefaultHttpDataFactory.MINSIZE属性的典型用法代码示例。如果您正苦于以下问题:Java DefaultHttpDataFactory.MINSIZE属性的具体用法?Java DefaultHttpDataFactory.MINSIZE怎么用?Java DefaultHttpDataFactory.MINSIZE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类io.netty.handler.codec.http.multipart.DefaultHttpDataFactory
的用法示例。
在下文中一共展示了DefaultHttpDataFactory.MINSIZE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHttpRequest
public void setHttpRequest(HttpRequest request) throws BadRequestException, IOException {
if (request == null) {
LOG.error("HttpRequest not initialized");
throw new BadRequestException("HttpRequest not initialized");
}
if (!request.getMethod().equals(HttpMethod.POST)) {
LOG.error("Got invalid HTTP method: expecting only POST");
throw new BadRequestException("Incorrect method "
+ request.getMethod().toString() + ", expected POST");
}
HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE);
HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(factory, request);
InterfaceHttpData data = decoder.getBodyHttpData(HTTP_TEST_ATTRIBUTE);
if (data == null) {
LOG.error("HTTP Resolve request inccorect, {} attribute not found", HTTP_TEST_ATTRIBUTE);
throw new BadRequestException("HTTP Resolve request inccorect, " +
HTTP_TEST_ATTRIBUTE + " attribute not found");
}
Attribute attribute = (Attribute) data;
requestData = attribute.get();
LOG.trace("Name {}, type {} found, data size {}", data.getName(), data.getHttpDataType().name(), requestData.length);
}
示例2: parse
@Override
public void parse() throws Exception {
LOG.trace("CommandName: " + COMMAND_NAME + ": Parse..");
HttpDataFactory factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE);
HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(factory, getRequest());
if (decoder.isMultipart()) {
LOG.trace("Chunked: " + HttpHeaders.isTransferEncodingChunked(getRequest()));
LOG.trace(": Multipart..");
List<InterfaceHttpData> datas = decoder.getBodyHttpDatas();
if (!datas.isEmpty()) {
for (InterfaceHttpData data : datas) {
LOG.trace("Multipart1 name " + data.getName() + " type " + data.getHttpDataType().name());
if (data.getHttpDataType() == HttpDataType.Attribute) {
Attribute attribute = (Attribute) data;
if (CommonEpConstans.REQUEST_SIGNATURE_ATTR_NAME.equals(data.getName())) {
requestSignature = attribute.get();
if (LOG.isTraceEnabled()) {
LOG.trace("Multipart name " + data.getName() + " type "
+ data.getHttpDataType().name() + " Signature set. size: "
+ requestSignature.length);
LOG.trace(MessageEncoderDecoder.bytesToHex(requestSignature));
}
} else if (CommonEpConstans.REQUEST_KEY_ATTR_NAME.equals(data.getName())) {
requestKey = attribute.get();
if (LOG.isTraceEnabled()) {
LOG.trace("Multipart name " + data.getName() + " type "
+ data.getHttpDataType().name() + " requestKey set. size: "
+ requestKey.length);
LOG.trace(MessageEncoderDecoder.bytesToHex(requestKey));
}
} else if (CommonEpConstans.REQUEST_DATA_ATTR_NAME.equals(data.getName())) {
requestData = attribute.get();
if (LOG.isTraceEnabled()) {
LOG.trace("Multipart name " + data.getName() + " type "
+ data.getHttpDataType().name() + " requestData set. size: "
+ requestData.length);
LOG.trace(MessageEncoderDecoder.bytesToHex(requestData));
}
} else if (CommonEpConstans.NEXT_PROTOCOL_ATTR_NAME.equals(data.getName())) {
nextProtocol = ByteBuffer.wrap(attribute.get()).getInt();
LOG.trace("[{}] next protocol is {}", getSessionUuid(), nextProtocol);
}
}
}
} else {
LOG.error("Multipart.. size 0");
throw new BadRequestException("HTTP Request inccorect, multiprat size is 0");
}
}
}
示例3: MyHttpPostRequestEncoder
/**
*
* @param request
* the request to encode
* @param multipart
* True if the FORM is a ENCTYPE="multipart/form-data"
* @throws NullPointerException
* for request
* @throws ErrorDataEncoderException
* if the request is not a POST
*/
public MyHttpPostRequestEncoder(HttpRequest request, boolean multipart) throws ErrorDataEncoderException {
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), request, multipart,
HttpConstants.DEFAULT_CHARSET, EncoderMode.RFC1738);
}