Examples of HttpPost


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

    @Override
    public void run() {
      try {
        final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        final HttpPost req = new HttpPost("http://datacleaner.eobjects.org/ws/user_action");
        nameValuePairs.add(new BasicNameValuePair("username", _username));
        nameValuePairs.add(new BasicNameValuePair("action", _action));
        nameValuePairs.add(new BasicNameValuePair("version", Main.VERSION));
        req.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse resp = HttpXmlUtils.getHttpClient().execute(req);
        InputStream content = resp.getEntity().getContent();
        String line = new BufferedReader(new InputStreamReader(content)).readLine();
        assert "success".equals(line);
View Full Code Here

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

  public static String getUrlContent(String url, Map<String, String> params) throws IOException {
    if (params == null) {
      params = Collections.emptyMap();
    }
    logger.info("getUrlContent({},{})", url, params);
    HttpPost method = new HttpPost(url);
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    for (Entry<String, String> entry : params.entrySet()) {
      nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }
    method.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String response = getHttpClient().execute(method, responseHandler);
    return response;
  }
View Full Code Here

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

  public XMLRPCClient(URI uri) {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", new PlainSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
   
    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

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

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

  }

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

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

        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

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

        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

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

       
        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

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

       
        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

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

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