View Javadoc
1   package com.foxinmy.weixin4j.http;
2   
3   import java.net.URI;
4   
5   import com.foxinmy.weixin4j.http.entity.HttpEntity;
6   
7   /**
8    * HTTP 请求
9    * 
10   * @className HttpRequest
11   * @author jinyu(foxinmy@gmail.com)
12   * @date 2015年5月29日
13   * @since JDK 1.6
14   * @see
15   */
16  public class HttpRequest implements HttpMessage {
17  	/**
18  	 * 请求方式
19  	 * 
20  	 * @return
21  	 */
22  	private final HttpMethod method;
23  
24  	/**
25  	 * 请求路径
26  	 * 
27  	 * @return
28  	 */
29  	private final URI uri;
30  	/**
31  	 * 内容参数
32  	 */
33  	private HttpEntity entity;
34  	/**
35  	 * 请求表头
36  	 */
37  	private HttpHeaders headers;
38  
39  	public HttpRequest(HttpMethod method, URI uri) {
40  		this.method = method;
41  		this.uri = uri;
42  	}
43  
44  	public HttpRequest(HttpMethod method, String url) {
45  		this(method, URI.create(url));
46  	}
47  
48  	public HttpMethod getMethod() {
49  		return method;
50  	}
51  
52  	public URI getURI() {
53  		return uri;
54  	}
55  
56  	public HttpEntity getEntity() {
57  		return entity;
58  	}
59  
60  	public void setEntity(HttpEntity entity) {
61  		this.entity = entity;
62  	}
63  
64  	public void setHeaders(HttpHeaders headers) {
65  		this.headers = headers;
66  	}
67  
68  	@Override
69  	public HttpHeaders getHeaders() {
70  		return headers;
71  	}
72  }