Package org.apache.commons.httpclient.methods

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


   */
  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

     *                          for the request's data.
     * @param   callback        Callback with HTTP method's response.
     */
    public void executePostMethod(byte[] input, ResponseCallback<?> callback) {
        executePostMethod(defaultUri, 
                          (input != null ? new ByteArrayRequestEntity(input) : null),
                          null, callback);
    }
View Full Code Here

                marshaller.marshal(requestPayload, new StreamResult(out));
            } catch (IOException e) {
                throw new MarshallingFailureException(e.getMessage(), e);
            }
           
            post.setRequestEntity(new ByteArrayRequestEntity(out.toByteArray()));
        }
       
        processHttpMethodParams(post, hParams);
       
        processHttpMethod(post, callback);
View Full Code Here

    Header headers[] = fRequestProperties.getAllHeaders();
    for (int i = 0; i < headers.length; i++) {
      fHttpRequestMethod.setRequestHeader(headers[i]);
    }
    if (fOutputStream != null) {
      ((EntityEnclosingMethod) fHttpRequestMethod).setRequestEntity(new ByteArrayRequestEntity(fOutputStream.toByteArray()));
    }
    responseCode = sHttpClient.executeMethod(fHttpRequestMethod);
    if (responseCode != HttpStatus.SC_OK) {
      LOG.error(fHttpRequestMethod.getName() + " " + url.toExternalForm() +" failed: " + fHttpRequestMethod.getStatusLine());
    }
View Full Code Here

        }

        meta.setHeader(Constants.HDR_ACCEPT, Constants.CTYPE_JSON);

        PutMethod put = new PutMethod(ClientUtils.makeURI(config, bucket));
        put.setRequestEntity(new ByteArrayRequestEntity(schema.toString().getBytes(), Constants.CTYPE_JSON));

        return executeMethod(bucket, null, put, meta);
    }
View Full Code Here

                                                                                        contentType));
                } else {
                    entityEnclosingMethod.setRequestEntity(new InputStreamRequestEntity(valueStream, contentType));
                }
            } else if (value != null) {
                entityEnclosingMethod.setRequestEntity(new ByteArrayRequestEntity(value, contentType));
            } else {
                entityEnclosingMethod.setRequestEntity(new ByteArrayRequestEntity("".getBytes(), contentType));
            }
        }
    }
View Full Code Here

            // 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.
            NameValuePair[] mvps = params.toArray(new NameValuePair[params.size()]);
            String content = EncodingUtil.formUrlEncode(mvps, getRequestCharSet());
            ByteArrayRequestEntity entity = new ByteArrayRequestEntity(
                    EncodingUtil.getAsciiBytes(content),
                    FORM_URL_ENCODED_CONTENT_TYPE
            );
            return entity;
        } else {
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

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.