Skip to content

Commit e82a01e

Browse files
committed
http comit
07/16
1 parent 0637a41 commit e82a01e

27 files changed

+1205
-0
lines changed

http/.classpath

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java1.8"/>
5+
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar" sourcepath="E:/JavaJar包整理/dom4j-1.6.1/dom4j-1.6.1"/>
6+
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
7+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
8+
<classpathentry kind="output" path="bin"/>
9+
</classpath>

http/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>http</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

http/404.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="Generator" content="EditPlus®">
6+
<meta name="Author" content="">
7+
<meta name="Keywords" content="">
8+
<meta name="Description" content="">
9+
<title>Document</title>
10+
</head>
11+
<body>
12+
<h1>404 NOT Found</h1>
13+
<strong style="color:red;">来自Han服务器</strong>
14+
</body>
15+
</html>

http/lib/dom4j-1.6.1.jar

307 KB
Binary file not shown.

http/lib/log4j-1.2.17.jar

478 KB
Binary file not shown.

http/login.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="Generator" content="EditPlus®">
6+
<meta name="Author" content="">
7+
<meta name="Keywords" content="">
8+
<meta name="Description" content="">
9+
<title>han登录</title>
10+
</head>
11+
<body>
12+
用户名:<input type="text" name="userName"><br/>
13+
密码:<input type="text" name="userName"><br/>
14+
</body>
15+
</html>

http/server.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<server>
3+
<port>8089</port>
4+
<serverName>Han`s Server</serverName>
5+
<!-- 默认编码为UTF-8 -->
6+
<charset>UTF-8</charset>
7+
</server>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.cszjo.com.http.context;
2+
3+
import java.nio.channels.SelectionKey;
4+
5+
/**
6+
* @Title: Context.java
7+
* @Description: Http上下文抽象类
8+
* @author: Han
9+
* @date: 2016年7月16日 下午2:19:06
10+
*/
11+
public abstract class Context {
12+
13+
protected Request request;
14+
protected Response response;
15+
16+
/**
17+
* 设置当前连接的上下文
18+
* @param: @return
19+
* @return: Context
20+
* @Autor: Han
21+
*/
22+
public abstract void setContext(String requestHeader, SelectionKey key);
23+
24+
/**
25+
* 得到Request
26+
* @param: @return
27+
* @return: Request
28+
* @Autor: Han
29+
*/
30+
public Request getRequest() {
31+
return request;
32+
}
33+
34+
/**
35+
* 得到Response
36+
* @param: @return
37+
* @return: Response
38+
* @Autor: Han
39+
*/
40+
public Response getResponse() {
41+
return response;
42+
}
43+
44+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.cszjo.com.http.context;
2+
3+
import java.util.Map;
4+
import java.util.Set;
5+
6+
/**
7+
* @Title: Request.java
8+
* @Description: 接口设计:Request接口
9+
* @author: Han
10+
* @date: 2016年7月15日 下午9:21:45
11+
*/
12+
public interface Request {
13+
14+
public static final String POST = "POST";
15+
16+
public static final String GET = "GET";
17+
/**
18+
* 得到参数
19+
* @param: @return
20+
* @return: Map<String,Object>
21+
* @Autor: Han
22+
*/
23+
public Map<String, Object> getAttribute();
24+
25+
/**
26+
* 得到请求方式
27+
* @param: @return
28+
* @return: String
29+
* @Autor: Han
30+
*/
31+
public String getMethod();
32+
33+
/**
34+
* 得到URI
35+
* @param: @return
36+
* @return: String
37+
* @Autor: Han
38+
*/
39+
public String getUri();
40+
41+
/**
42+
* 版本协议
43+
* @param: @return
44+
* @return: String
45+
* @Autor: Han
46+
*/
47+
public String getProtocol();
48+
49+
/**
50+
* 得到请求头Map
51+
* @param: @return
52+
* @return: String
53+
* @Autor: Han
54+
*/
55+
public Map<String, Object> getHeaders();
56+
57+
/**
58+
* 得到请求头参数集合
59+
* @param: @return
60+
* @return: String
61+
* @Autor: Han
62+
*/
63+
public Set<String> getHeaderNames();
64+
65+
/**
66+
* 根据请求头名得到对应的请求头
67+
* @param: @return
68+
* @return: String
69+
* @Autor: Han
70+
*/
71+
public Object getHeader(String key);
72+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.cszjo.com.http.context;
2+
3+
import java.nio.channels.SelectionKey;
4+
5+
import com.cszjo.com.http.utils.XMLUtil;
6+
7+
/**
8+
* @Title: Response.java
9+
* @Description: 接口设计:response接口
10+
* @author: Han
11+
* @date: 2016年7月16日 下午2:19:25
12+
*/
13+
public interface Response {
14+
15+
//服务器名字
16+
public static final String SERVER_NAME = XMLUtil.getRootElement("server.xml").element("serverName").getText();
17+
18+
public String getContentType();
19+
20+
public int getStatuCode();
21+
22+
public String getStatuCodeStr();
23+
24+
public String getHtmlFile();
25+
26+
public void setHtmlFile(String htmlFile);
27+
28+
public SelectionKey getKey();
29+
30+
public void setContentType(String contentType);
31+
32+
public void setStatuCode(int statuCode);
33+
34+
public void setStatuCodeStr(String statuCodeStr);
35+
}

0 commit comments

Comments
 (0)