当前位置: 首页>>代码示例>>Java>>正文


Java ContentLengthStrategy.IDENTITY属性代码示例

本文整理汇总了Java中org.apache.http.entity.ContentLengthStrategy.IDENTITY属性的典型用法代码示例。如果您正苦于以下问题:Java ContentLengthStrategy.IDENTITY属性的具体用法?Java ContentLengthStrategy.IDENTITY怎么用?Java ContentLengthStrategy.IDENTITY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.entity.ContentLengthStrategy的用法示例。


在下文中一共展示了ContentLengthStrategy.IDENTITY属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receiveRequest

public HttpRequest receiveRequest() throws HttpException, IOException {
    HttpRequest request = (HttpRequest) this.requestParser.parse();
    if (HEADERLOG.isDebugEnabled()) {
        HEADERLOG.debug(">> " + request.getRequestLine().toString());
        for (HeaderIterator it = request.headerIterator(); it.hasNext(); ) {
            HEADERLOG.debug(">> " + it.nextHeader().toString());
        }
    }
    
    // Prepare input stream
    this.in = null;
    if (request instanceof HttpEntityEnclosingRequest) {
        long len = this.contentLenStrategy.determineLength(request);
        if (len == ContentLengthStrategy.CHUNKED) {
            this.in = new ChunkedInputStream(this.inbuffer);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            this.in = new IdentityInputStream(this.inbuffer);                            
        } else {
            this.in = new ContentLengthInputStream(inbuffer, len);
        }
    }
    return request;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:AxisHttpConnectionImpl.java

示例2: doDeserialize

/**
 * Creates a {@link BasicHttpEntity} based on properties of the given
 * message. The content of the entity is created by wrapping
 * {@link SessionInputBuffer} with a content decoder depending on the
 * transfer mechanism used by the message.
 * <p>
 * This method is called by the public
 * {@link #deserialize(SessionInputBuffer, HttpMessage)}.
 *
 * @param inbuffer the session input buffer.
 * @param message the message.
 * @return HTTP entity.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
protected BasicHttpEntity doDeserialize(
        final SessionInputBuffer inbuffer,
        final HttpMessage message) throws HttpException, IOException {
    BasicHttpEntity entity = new BasicHttpEntity();

    long len = this.lenStrategy.determineLength(message);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(new ChunkedInputStream(inbuffer));
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(new IdentityInputStream(inbuffer));
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(new ContentLengthInputStream(inbuffer, len));
    }

    Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:EntityDeserializer.java

示例3: determineLength

public long determineLength(final HttpMessage message) throws HttpException {
    long result = this.contentLengthStrategy.determineLength(message);
    if (result == ContentLengthStrategy.IDENTITY) {
        throw new ProtocolException("Identity transfer encoding cannot be used");
    }
    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:DisallowIdentityContentLengthStrategy.java

示例4: determineLength

public long determineLength(final HttpMessage message) throws HttpException {
    final long result = this.contentLengthStrategy.determineLength(message);
    if (result == ContentLengthStrategy.IDENTITY) {
        throw new ProtocolException("Identity transfer encoding cannot be used");
    }
    return result;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:7,代码来源:DisallowIdentityContentLengthStrategy.java

示例5: createOutputStream

protected OutputStream createOutputStream(
        final long len,
        final SessionOutputBuffer outbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStreamHC4(2048, outbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityOutputStreamHC4(outbuffer);
    } else {
        return new ContentLengthOutputStreamHC4(outbuffer, len);
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:11,代码来源:BHttpConnectionBase.java

示例6: createInputStream

protected InputStream createInputStream(
        final long len,
        final SessionInputBuffer inbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedInputStreamHC4(inbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityInputStreamHC4(inbuffer);
    } else {
        return new ContentLengthInputStreamHC4(inbuffer, len);
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:11,代码来源:BHttpConnectionBase.java

示例7: prepareInput

protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
    final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();

    final long len = this.incomingContentStrategy.determineLength(message);
    final InputStream instream = createInputStream(len, this.inbuffer);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(instream);
    }

    final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:29,代码来源:BHttpConnectionBase.java

示例8: doSerialize

/**
 * Creates a transfer codec based on properties of the given HTTP message
 * and returns {@link OutputStream} instance that transparently encodes
 * output data as it is being written out to the output stream.
 * <p>
 * This method is called by the public
 * {@link #serialize(SessionOutputBuffer, HttpMessage, HttpEntity)}.
 *
 * @param outbuffer the session output buffer.
 * @param message the HTTP message.
 * @return output stream.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
protected OutputStream doSerialize(
        final SessionOutputBuffer outbuffer,
        final HttpMessage message) throws HttpException, IOException {
    long len = this.lenStrategy.determineLength(message);
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStream(outbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityOutputStream(outbuffer);
    } else {
        return new ContentLengthOutputStream(outbuffer, len);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:EntitySerializer.java


注:本文中的org.apache.http.entity.ContentLengthStrategy.IDENTITY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。