What is the getParams () method for the HttpGet method?

org.apache.http.client.methods.HttpGet;

HttpGet method = new HttpGet(url.toExternalForm());
method.getParams()

What are these options? Are they a query string? there seems to be no easy way to add a query string with org.apache.http.client.methods.HttpGet

+5
source share
3 answers

According to the Http Client , you can do this:

URI uri = new URIBuilder()
        .setScheme("http")
        .setHost("www.google.com")
        .setPath("/search")
        .setParameter("q", "httpclient")
        .setParameter("btnG", "Google Search")
        .setParameter("aq", "f")
        .setParameter("oq", "")
        .build();
HttpGet httpget = new HttpGet(uri);
System.out.println(httpget.getURI());
+14
source

These parameters are HTTP GET request parameters.

For example, in the URL http://www.mysite.com/login?username=mcjones, the parameter name is mcjones.

0
source

http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethodBase.html#getParams%28%29:

getParams

public HttpMethodParams getParams()

Returns HTTP protocol parameters associated with this method.

Specified by:
    getParams in interface HttpMethod

Returns:
    HTTP parameters.
Since:
    3.0
See Also:
    HttpMethodParams

A complete list of request parameters can be found at http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html

0
source

All Articles