Java 类org.apache.commons.httpclient.HttpConstants 实例源码

项目:jrpip    文件:StreamedPostMethod.java   
protected void flushCache() throws IOException
{
    if (this.cachePosition > 0)
    {
        this.writeHeaders();
        byte[] chunkHeader = HttpConstants.getBytes(
                Integer.toHexString(this.cachePosition) + "\r\n");
        this.stream.write(chunkHeader, 0, chunkHeader.length);
        this.stream.write(this.cache, 0, this.cachePosition);
        this.stream.write(ENDCHUNK, 0, ENDCHUNK.length);
        this.cachePosition = 0;
    }
}
项目:jrpip    文件:StreamedPostMethod.java   
protected void flushCacheWithAppend(byte[] bufferToAppend, int off, int len) throws IOException
{
    this.writeHeaders();
    byte[] chunkHeader = HttpConstants.getBytes(
            Integer.toHexString(this.cachePosition + len) + "\r\n");
    this.stream.write(chunkHeader, 0, chunkHeader.length);
    this.stream.write(this.cache, 0, this.cachePosition);
    this.stream.write(bufferToAppend, off, len);
    this.stream.write(ENDCHUNK, 0, ENDCHUNK.length);
    this.cachePosition = 0;
}
项目:apm-agent    文件:ExecuteInterceptor.java   
private void recordEntity(HttpMethod httpMethod, Trace trace) {
    if (httpMethod instanceof EntityEnclosingMethod) {
        final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod)httpMethod;
        final RequestEntity entity = entityEnclosingMethod.getRequestEntity();

        if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) {
            if (entitySampler.isSampling()) {
                try {
                    String entityValue;
                    String charSet = entityEnclosingMethod.getRequestCharSet();

                    if (charSet == null || charSet.isEmpty()) {
                        charSet = HttpConstants.DEFAULT_CONTENT_CHARSET;
                    }
                    if (entity instanceof ByteArrayRequestEntity) {
                        entityValue = readByteArray((ByteArrayRequestEntity)entity, charSet);
                    } else if (entity instanceof StringRequestEntity) {
                        entityValue = readString((StringRequestEntity)entity);
                    } else {
                        entityValue = entity.getClass() + " (ContentType:" + entity.getContentType() + ")";
                    }

                    trace.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, entityValue);
                } catch (Exception e) {
                    logger.debug("HttpEntityEnclosingRequest entity record fail. Caused:{}", e.getMessage(), e);
                }
            }
        }
    }

}
项目:pinpoint    文件:HttpMethodBaseExecuteMethodInterceptor.java   
private void recordEntity(HttpMethod httpMethod, Trace trace) {
    if (httpMethod instanceof EntityEnclosingMethod) {
        final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) httpMethod;
        final RequestEntity entity = entityEnclosingMethod.getRequestEntity();

        if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) {
            if (entitySampler.isSampling()) {
                try {
                    String entityValue;
                    String charSet = entityEnclosingMethod.getRequestCharSet();

                    if (StringUtils.isEmpty(charSet)) {
                        charSet = HttpConstants.DEFAULT_CONTENT_CHARSET;
                    }

                    if (entity instanceof ByteArrayRequestEntity || entity instanceof StringRequestEntity) {
                        entityValue = entityUtilsToString(entity, charSet);
                    } else {
                        entityValue = entity.getClass() + " (ContentType:" + entity.getContentType() + ")";
                    }

                    final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
                    recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, entityValue);
                } catch (Exception e) {
                    logger.debug("HttpEntityEnclosingRequest entity record fail. Caused:{}", e.getMessage(), e);
                }
            }
        }
    }
}
项目:jakarta-slide-webdavclient    文件:HttpRequestBodyMethodBase.java   
/**
 * Set my request body content to the contents of a string.
 *
 * @since 2.0
 */
public void setRequestBody(String bodydata) {
    checkNotUsed();
    setRequestBody(HttpConstants.getContentBytes(bodydata, getRequestCharSet()));
}