1234567891011121314151617181920212223242526272829303132 |
- package cn.hhj.bio.tomcat.http;
- import java.io.InputStream;
- public class Request {
- private String method;
- private String url;
- public Request(InputStream in)throws Exception{
- //拿到HTTP协议内容
- String content = "";
- byte[] buffer=new byte[1024];
- int len = 0;
- if ((len = in.read(buffer)) > 0) {
- content = new String(buffer,0,len);
- }
- String line = content.split("\\n")[0];
- String [] arr = line.split("\\s");
- this.method = arr[0];
- this.url = arr[1].split("\\?")[0];
- System.err.println(content);
- }
- public String getUrl() {
- return url;
- }
- public String getMethod() {
- return method;
- }
- }
|