Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpPost


   * @param XMLRPC server URI
   * @param HttpClient to use
   */
 
  public XMLRPCClient(URI uri, HttpClient client) {
    postMethod = new HttpPost(uri);
    postMethod.addHeader("Content-Type", "text/xml");
   
    // WARNING
    // I had to disable "Expect: 100-Continue" header since I had
    // two second delay between sending http POST request and POST body
View Full Code Here


  }

  @Before
  public void setUp() {
    httpClient = new DefaultHttpClient();
    postRequest = new HttpPost("http://0.0.0.0:41404");
  }
View Full Code Here

        final String  message = "Hello, world!";
        final String  charset = "UTF-8";
        final HttpHost target = getServerHttp();

        HttpPost request = new HttpPost("/echo/");
        request.setHeader("Host", target.getHostName());
        request.setEntity(new StringEntity(message, charset));

        HttpClientConnection conn = connectTo(target);

        httpContext.setAttribute(
                ExecutionContext.HTTP_CONNECTION, conn);
        httpContext.setAttribute(
                ExecutionContext.HTTP_TARGET_HOST, target);
        httpContext.setAttribute(
                ExecutionContext.HTTP_REQUEST, request);

        request.setParams(
                new DefaultedHttpParams(request.getParams(), defaultParams));
        httpExecutor.preProcess
            (request, httpProcessor, httpContext);
        HttpResponse response = httpExecutor.execute
            (request, conn, httpContext);
        response.setParams(
View Full Code Here

        this.localServer.register("*", new BasicRedirectService(host, port));

        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();
       
        HttpPost httppost = new HttpPost("/oldlocation/");
        httppost.setEntity(new StringEntity("stuff"));

        HttpResponse response = client.execute(getServerHttp(), httppost, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
View Full Code Here

       
        FaultyHttpClient client = new FaultyHttpClient();
        HttpContext context = new BasicHttpContext();

        String s = "http://localhost:" + port;
        HttpPost httppost = new HttpPost(s);
        httppost.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));

        try {
View Full Code Here

       
        HttpRequestBase httpRequest = null;
        try {
            URI uri = url.toURI();
            if (method.equals(POST)) {
                httpRequest = new HttpPost(uri);
            } else if (method.equals(PUT)) {
                httpRequest = new HttpPut(uri);
            } else if (method.equals(HEAD)) {
                httpRequest = new HttpHead(uri);
            } else if (method.equals(TRACE)) {
View Full Code Here

    /** Build a POST request to specified path with optional query
     *  parameters. See {@link #buildUrl(String, String...)} for
     *  queryParameters semantics.
     */
    public Request buildPostRequest(String path) {
        return new Request(new HttpPost(buildUrl(path)));
    }
View Full Code Here

  protected InputStream sendPostRequest(String serviceURL,
      String requestBody, String contentType) {
    HttpClient httpclient = ogpHttpClient.getHttpClient();
    InputStream replyStream = null;
    try {
      HttpPost httppost = new HttpPost(serviceURL);
      logger.debug(requestBody);
      StringEntity postEntity = new StringEntity(requestBody, ContentType.create(contentType, "UTF-8"));
      httppost.setEntity(postEntity);
      logger.info("executing POST request to " + httppost.getURI());
      HttpResponse response = httpclient.execute(httppost);
      this.setStatus(response.getStatusLine().getStatusCode());
      this.setHeaders(response.getAllHeaders());
      HttpEntity entity = response.getEntity();
     
View Full Code Here

          foundMatch=true;
      if (!foundMatch)
        Assert.fail(String.format("Could not find request header matching: %s", header));
    }
    if(request instanceof HttpPost) {
      HttpPost post = (HttpPost)request;
      HttpEntity entity = post.getEntity();
      Parameters actualParameters = extractParameters(entity);

      String [] expectedNames = parameters.getNames();
      String [] actualNames = actualParameters.getNames();
      Arrays.sort(expectedNames);
View Full Code Here

    }
  }

  private void assertParameters(final HttpRequestBase request) throws ArrayComparisonFailure {
    if(request instanceof HttpPost) {
      HttpPost post = (HttpPost)request;
      HttpEntity entity = post.getEntity();
      Parameters actualParameters = extractParameters(entity);

      String [] expectedNames = parameters.getNames();
      String [] actualNames = actualParameters.getNames();
      Arrays.sort(expectedNames);
View Full Code Here

TOP

Related Classes of org.apache.http.client.methods.HttpPost

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.