Examples of HttpPost


Examples of com.belladati.httpclientandroidlib.client.methods.HttpPost

    return post(relativeUrl, tokenHolder, null, parameters);
  }

  public byte[] post(String relativeUrl, TokenHolder tokenHolder, HttpParameters oauthParams,
    List<? extends NameValuePair> parameters) {
    HttpPost post = new HttpPost(baseUrl + relativeUrl);
    if (parameters != null) {
      try {
        post.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
      } catch (UnsupportedEncodingException e) {
        throw new IllegalArgumentException("Invalid URL encoding", e);
      }
    }
    return doRequest(post, tokenHolder, oauthParams);
View Full Code Here

Examples of de.FBEditor.struct.HttpPost

        language = fbfwvn.getFritzboxLanguage().toLowerCase();
      }

    } else {

      HttpPost http = new HttpPost();
      boolean isQueryOld = false;
      String url = urlstr;
      String sRetQueryOld = "";
      String sRetQueryNew = "";
      postdata = "sid=" + sRetSID + "&"
          + "getpage=../html/query.txt&var:cnt=1" + "&var:n" + "0"
          + "=" + "logic:status/nspver";
      sRetQueryOld = http.Post2(url, postdata);
      postdata = "sid=" + sRetSID + "&"
          + "getpage=../html/query.txt&var:cnt=1" + "&var:n[" + "0"
          + "]=" + "logic:status/nspver";
      sRetQueryNew = http.Post2(url, postdata);

      if (sRetQueryOld.length() > sRetQueryNew.length()) {
        isQueryOld = true;
        data = sRetQueryOld;
      } else {
View Full Code Here

Examples of de.FBEditor.struct.HttpPost

  public FritzBoxFirmware getFirmware() {
    return firmware;
  }

  public String getFirmwareStatus() {
    HttpPost http = new HttpPost();
    String url = (new StringBuilder("http://"))
        .append(FBEdit.getInstance().getbox_address())
        .append("/cgi-bin/system_status").toString();
    String sFBFW_Status = http.Post(url, "");
    return sFBFW_Status;
  }
View Full Code Here

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

    headers.add(new BasicHeader("Connection", "Close"));
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.default-headers", headers);

    HttpClient httpclient = new DefaultHttpClient(params);
    HttpPost httppost = new HttpPost("http://localhost:" + PORT + "/post");
    HttpResponse response = httpclient.execute(httppost);

    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
View Full Code Here

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

  @Test
  public void smallHttpPostBodyWithUnusualCharactersTest() throws ClientProtocolException, IOException {
    final String body = "Räger Schildmäijår";
   
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://localhost:" + PORT + "/echo");
    httppost.setEntity(new StringEntity(body))// HTTP 1.1 says that the default charset is ISO-8859-1
    HttpResponse response = httpclient.execute(httppost)
   
    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
View Full Code Here

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

      {
         return new HttpGet(url);
      }
      else if ("POST".equals(restVerb))
      {
         return new HttpPost(url);
      }
      else if ("DELETE".equals(restVerb))
      {
         return new HttpDelete(url);
      }
      else
      {
         final String verb = restVerb;
         return new HttpPost(url)
         {
            @Override
            public String getMethod()
            {
               return verb;
View Full Code Here

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

         throw new RuntimeException("You cannot send both form parameters and an entity body");

      if (!request.getFormParameters().isEmpty())
      {
         commitHeaders(request, httpMethod);
         HttpPost post = (HttpPost) httpMethod;

         List<NameValuePair> formparams = new ArrayList<NameValuePair>();

         for (Map.Entry<String, List<String>> formParam : request.getFormParameters().entrySet())
         {
            List<String> values = formParam.getValue();
            for (String value : values)
            {
               formparams.add(new BasicNameValuePair(formParam.getKey(), value));
            }
         }

         UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
         post.setEntity(entity);
      }
      else if (request.getBody() != null)
      {
         if (httpMethod instanceof HttpGet) throw new RuntimeException("A GET request cannot have a body.");

         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try
         {
            request.writeRequestBody(request.getHeadersAsObjects(), baos);
            ByteArrayEntity entity = new ByteArrayEntity(baos.toByteArray())
            {
               @Override
               public Header getContentType()
               {
                  return new BasicHeader("Content-Type", request.getBodyContentType().toString());
               }
            };
            HttpPost post = (HttpPost) httpMethod;
            commitHeaders(request, httpMethod);
            post.setEntity(entity);
         }
         catch (IOException e)
         {
            throw new RuntimeException(e);
         }
View Full Code Here

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

     * @throws IOException
     */
    public void POST(final String uri, final InputStream instream, final long length) throws IOException {
      if (this.currentRequest != null) throw new IOException("Client is in use!");
        final MultiProtocolURI url = new MultiProtocolURI(uri);
        final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
        String host = url.getHost();
        if (host == null) host = "127.0.0.1";
        setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service
        final NonClosingInputStreamEntity inputStreamEntity = new NonClosingInputStreamEntity(instream, length);
      // statistics
      this.upbytes = length;
      httpPost.setEntity(inputStreamEntity);
      this.currentRequest = httpPost;
      execute(httpPost);
    }
View Full Code Here

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

     * @param usegzip if the body should be gzipped
     * @return response body
     * @throws IOException
     */
    public byte[] POSTbytes(final MultiProtocolURI url, final String vhost, final Map<String, ContentBody> post, final boolean usegzip) throws IOException {
      final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));

        setHost(vhost); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service
      if (vhost == null) setHost("127.0.0.1");

        final MultipartEntity multipartEntity = new MultipartEntity();
        for (final Entry<String,ContentBody> part : post.entrySet())
            multipartEntity.addPart(part.getKey(), part.getValue());
        // statistics
        this.upbytes = multipartEntity.getContentLength();

        if (usegzip) {
            httpPost.setEntity(new GzipCompressingEntity(multipartEntity));
        } else {
            httpPost.setEntity(multipartEntity);
        }

        return getContentBytes(httpPost, Long.MAX_VALUE);
    }
View Full Code Here

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

     * @return content bytes
     * @throws IOException
     */
    public byte[] POSTbytes(final String uri, final InputStream instream, final long length) throws IOException {
        final MultiProtocolURI url = new MultiProtocolURI(uri);
        final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
        String host = url.getHost();
        if (host == null) host = "127.0.0.1";
        setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service

        final InputStreamEntity inputStreamEntity = new InputStreamEntity(instream, length);
        // statistics
        this.upbytes = length;
        httpPost.setEntity(inputStreamEntity);
        return getContentBytes(httpPost, Long.MAX_VALUE);
    }
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.