Package org.apache.commons.httpclient.methods

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


    if (body != null && body.length() > 0) {
      EntityEnclosingMethod generic = (EntityEnclosingMethod) httpMethod;
      // generic.setRequestEntity(new
      // StringRequestEntity(body.toString()));
      generic
          .setRequestEntity(new ByteArrayRequestEntity(body
              .getBytes()));

    }

    httpMethod.setFollowRedirects(false);
View Full Code Here


    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

      // 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 {
      return super.generateRequestEntity();
View Full Code Here

            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

            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

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

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

   */
  public Response put(Cluster cluster, String path, Header[] headers,
      byte[] content) throws IOException {
    PutMethod method = new PutMethod();
    try {
      method.setRequestEntity(new ByteArrayRequestEntity(content));
      int code = execute(cluster, method, headers, path);
      headers = method.getResponseHeaders();
      content = method.getResponseBody();
      return new Response(code, headers, content);
    } finally {
View Full Code Here

   */
  public Response post(Cluster cluster, String path, Header[] headers,
      byte[] content) throws IOException {
    PostMethod method = new PostMethod();
    try {
      method.setRequestEntity(new ByteArrayRequestEntity(content));
      int code = execute(cluster, method, headers, path);
      headers = method.getResponseHeaders();
      content = method.getResponseBody();
      return new Response(code, headers, content);
    } finally {
View Full Code Here

   */
  public Response put(Cluster cluster, String path, Header[] headers,
      byte[] content) throws IOException {
    PutMethod method = new PutMethod();
    try {
      method.setRequestEntity(new ByteArrayRequestEntity(content));
      int code = execute(cluster, method, headers, path);
      headers = method.getResponseHeaders();
      content = method.getResponseBody();
      return new Response(code, headers, content);
    } finally {
View Full Code Here

   */
  public Response post(Cluster cluster, String path, Header[] headers,
      byte[] content) throws IOException {
    PostMethod method = new PostMethod();
    try {
      method.setRequestEntity(new ByteArrayRequestEntity(content));
      int code = execute(cluster, method, headers, path);
      headers = method.getResponseHeaders();
      content = method.getResponseBody();
      return new Response(code, headers, content);
    } finally {
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.ByteArrayRequestEntity

Copyright © 2018 www.massapicom. 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.