Examples of ByteArrayRequestEntity


Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

    // set body if post method or put method
    if (body != null && body.length() > 0 && (httpMethod instanceof PostMethod || httpMethod instanceof PutMethod)) {
      EntityEnclosingMethod post = (EntityEnclosingMethod) httpMethod;
//      post.setRequestEntity(new StringRequestEntity(body.toString()));
            post.setRequestEntity(new ByteArrayRequestEntity(body.getBytes()));

    }

    httpMethod.setFollowRedirects(false);
    return httpMethod;
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

            // This is to avoid potential encoding issues.  Form url encoded strings
            // are ASCII by definition but the content type may not be.  Treating the content
            // as bytes allows us to keep the current charset without worrying about how
            // this charset will effect the encoding of the form url encoded string.
            String content = EncodingUtil.formUrlEncode(getParameters(), getRequestCharSet());
            ByteArrayRequestEntity entity = new ByteArrayRequestEntity(
                EncodingUtil.getAsciiBytes(content),
                FORM_URL_ENCODED_CONTENT_TYPE
            );
            return entity;
        } else {
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

        if (lf.getConfiguration().isStreamingEnabled()) {
            return new StreamingRequestEntity(writer);
        } else {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            writer.write(baos);
            return new ByteArrayRequestEntity(baos.toByteArray(), writer.getContentType());
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

            ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
            for (int c = 0; c < 5000000; ++c) {
                originalContent.write(c);
            }
            byte[] entity = originalContent.toByteArray();
            postMethod.setRequestEntity(new ByteArrayRequestEntity(entity, "text/xml"));
            client.executeMethod(postMethod);
            assertEquals(277, postMethod.getStatusCode());

            InputStream respStream = postMethod.getResponseBodyAsStream();
            for (int c = 0; c < entity.length; ++c) {
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

            ByteArrayOutputStream originalContent = new ByteArrayOutputStream();
            for (int c = 0; c < 5000000; ++c) {
                originalContent.write(c);
            }
            byte[] entity = originalContent.toByteArray();
            postMethod.setRequestEntity(new ByteArrayRequestEntity(entity, "text/xml"));
            client.executeMethod(postMethod);
            assertEquals(277, postMethod.getStatusCode());

            InputStream respStream = postMethod.getResponseBodyAsStream();
            for (int c = 0; c < entity.length; ++c) {
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

  public Response post(String path, String mimeType, byte[] body) throws IOException {
    PostMethod post = new PostMethod(makeUrl(path));

    post.setFollowRedirects(false);
    addHeaders(post, getHeadersForPost(mimeType));
    post.setRequestEntity(new ByteArrayRequestEntity(body));
    httpClient.executeMethod(post);
    return createResponse(post);
  }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

   */
  protected void setRequestBody(
      HttpInvokerClientConfiguration config, PostMethod postMethod, ByteArrayOutputStream baos)
      throws IOException {

    postMethod.setRequestEntity(new ByteArrayRequestEntity(baos.toByteArray(), getContentType()));
  }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

        httpMethod.addRequestHeader(headerName, headerValue);
      }
    }
    if (this.httpMethod instanceof EntityEnclosingMethod) {
      EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) this.httpMethod;
      RequestEntity requestEntity = new ByteArrayRequestEntity(output);
      entityEnclosingMethod.setRequestEntity(requestEntity);
    }
    this.httpClient.executeMethod(this.httpMethod);
    return new CommonsClientHttpResponse(this.httpMethod);
  }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

                        // serialized java object
                        Serializable obj = in.getMandatoryBody(Serializable.class);
                        // write object to output stream
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        HttpHelper.writeObjectToStream(bos, obj);
                        answer = new ByteArrayRequestEntity(bos.toByteArray(), HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
                        IOHelper.close(bos);
                    } else if (data instanceof File || data instanceof GenericFile) {
                        // file based (could potentially also be a FTP file etc)
                        File file = in.getBody(File.class);
                        if (file != null) {
View Full Code Here

Examples of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

   */
  protected void setRequestBody(
      HttpInvokerClientConfiguration config, PostMethod postMethod, ByteArrayOutputStream baos)
      throws IOException {

    postMethod.setRequestEntity(new ByteArrayRequestEntity(baos.toByteArray(), getContentType()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.