All HTTP requests have a request line consisting a method name, a request URI and an HTTP protocol version.
HttpClient supports out of the box all HTTP methods defined in the HTTP/1.1 specification: GET, HEAD, POST, PUT, DELETE, TRACE and OPTIONS. There is a specific class for each method type.: HttpGet, HttpHead, HttpPost, HttpPut, HttpDelete, HttpTrace, and HttpOptions.
The Request-URI is a Uniform Resource Identifier that identifies the resource upon which to apply the request. HTTP request URIs consist of a protocol scheme, host name, optional port, resource path, optional query, and optional fragment.
所有的HTTP请求有一个请求线构成的方法名称,请求的URI和HTTP协议版本。
HttpClient支持开箱在HTTP / 1.1规范定义的所有HTTP方法得到,头后,把,删除,跟踪选项。对于每个方法类型特定的类:HttpGet、httphead,HttpPost、HttpPut、httpdelete,httptrace,和httpoptions。
请求URI是统一资源标识符标识应用请求的资源。HTTP请求的URI是一个协议,主机名,选择港,资源路径,可选的查询,和可选的片段。
HttpGet httpget = new HttpGet(
"http://www.google.com/search?hl=en&q=httpclient&btnG=Google+Search&aq=f&oq=");
HttpClient provides URIBuilder utility class to simplify creation and modification of request URIs.
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());
stdout >
http://www.google.com/search?q=httpclient&btnG=Google+Search&aq=f&oq=