Example usage for org.apache.commons.httpclient.methods InputStreamRequestEntity CONTENT_LENGTH_AUTO

List of usage examples for org.apache.commons.httpclient.methods InputStreamRequestEntity CONTENT_LENGTH_AUTO

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods InputStreamRequestEntity CONTENT_LENGTH_AUTO.

Prototype

int CONTENT_LENGTH_AUTO

To view the source code for org.apache.commons.httpclient.methods InputStreamRequestEntity CONTENT_LENGTH_AUTO.

Click Source Link

Usage

From source file:com.hp.alm.ali.rest.client.InputData.java

public static InputData create(String data, Map<String, String> headers) {
    return new InputData(null, InputStreamRequestEntity.CONTENT_LENGTH_AUTO, data, headers);
}

From source file:com.hp.alm.ali.rest.client.InputData.java

public static InputData create(InputStream bodyStream, Map<String, String> headers) {
    return new InputData(bodyStream, InputStreamRequestEntity.CONTENT_LENGTH_AUTO, null, headers);
}

From source file:com.hp.alm.ali.rest.client.InputData.java

public static InputData create(InputStream bodyStream) {
    return new InputData(bodyStream, InputStreamRequestEntity.CONTENT_LENGTH_AUTO, null,
            Collections.<String, String>emptyMap());
}

From source file:com.hp.alm.ali.rest.client.InputData.java

public static InputData create(String data) {
    return new InputData(null, InputStreamRequestEntity.CONTENT_LENGTH_AUTO, data,
            Collections.<String, String>emptyMap());
}

From source file:com.zimbra.common.httpclient.HttpClientUtil.java

public static <T extends EntityEnclosingMethod> T addInputStreamToHttpMethod(T method, InputStream is,
        long size, String contentType) {
    if (size < 0) {
        size = InputStreamRequestEntity.CONTENT_LENGTH_AUTO;
    }//from   w  w w.ja  va2 s.c o  m
    method.setRequestEntity(new InputStreamRequestEntity(is, size, contentType));
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new InputStreamRequestHttpRetryHandler());
    return method;
}

From source file:org.alfresco.custom.rest.httpconnector.RemoteClientImpl.java

private void preparePostPutRequest(ContentType contentType, InputStream in,
        org.apache.commons.httpclient.HttpMethod method) {
    method.setRequestHeader("Content-Type", contentType.value());

    // apply content-length here if known (i.e. from proxied req)
    // if this is not set, then the content will be buffered in memory
    int contentLength = InputStreamRequestEntity.CONTENT_LENGTH_AUTO;

    ((EntityEnclosingMethod) method).setRequestEntity(new InputStreamRequestEntity(in, contentLength));
}

From source file:org.eclipse.ecf.remoteservice.rest.client.AbstractEntityRequestType.java

public AbstractEntityRequestType(int requestEntityType, String defaultContentType, Map defaultRequestHeaders) {
    this(requestEntityType, defaultContentType, InputStreamRequestEntity.CONTENT_LENGTH_AUTO, null,
            defaultRequestHeaders);//from   w  ww.j a  v  a2  s . com
}

From source file:org.eclipse.ecf.remoteservice.rest.client.AbstractEntityRequestType.java

protected long getContentLength(IRemoteCall call, IRemoteCallable callable, IRemoteCallParameter paramDefault) {
    IRemoteCallParameter[] defaultParameters = callable.getDefaultParameters();
    Object[] parameters = call.getParameters();
    if (defaultParameters != null) {
        for (int i = 0; i < defaultParameters.length; i++) {
            if (CONTENT_LENGTH_PARAM_NAME.equals(defaultParameters[i].getName())) {
                Object o = (parameters != null && parameters.length > i) ? parameters[i] : defaultParameters[i];
                if (o instanceof Number) {
                    return ((Number) o).longValue();
                } else if (o instanceof String) {
                    try {
                        return Integer.parseInt((String) o);
                    } catch (NumberFormatException e) {
                        return InputStreamRequestEntity.CONTENT_LENGTH_AUTO;
                    }//from w  w w.  jav a  2  s.c  o m
                }
            }
        }
    }
    return defaultContentLength;
}