我创建了一个http服务器,开启服务器,输入网页后,控制台打印出的信息如下,里面有好几个信息老有重复的,求解

昨夜的雨 2017-11-24 03:45:13
控制台信息:
POST /index.html HTTP/1.1
POST /index.html HTTP/1.1
Host: localhost:8081
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
POST /index.html HTTP/1.1
Host: localhost:8081
Connection: keep-alive
Content-Length: 14
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8

http服务器代码:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/*
* 创建服务器,并启动
*/
public class Server {
//声明服务器
private ServerSocket server;
private Socket client;
public static void main(String[] args) {

Server server = new Server();
server.start();



}
/*
* 启动方法
*/

public void start() {
try {
server = new ServerSocket(8081);
this.receive();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

/*
* 接受客户端
*/
private void receive() {

try {
client = server.accept();
StringBuilder sb = new StringBuilder();
String msg = null;//声明一个变量,用来表示接收客户端的请求信息
BufferedReader br = new BufferedReader(
new InputStreamReader(client.getInputStream()));
while((msg = br.readLine()).length() > 0) {
sb.append(msg);
sb.append("\r\n");

if(msg == null) {
break;
}
String requestInfo = sb.toString().trim();
System.out.println(requestInfo);

}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

/*
* 停止服务器
*/

public void stop() {

}



}

...全文
241 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文详细介绍了一个基于C++语言开发的疫苗接种和儿童体检系统的设计与实现全过程,涵盖项目背景、目标意义、架构设计、核心功能模块、数据库实现、API接口规范、前后端代码实现及部署应用等多个方面。系统采用分层架构与模块化设计,实现了儿童信息管理、疫苗接种记录、体检数据录入、多用户权限控制、数据统计分析、异常预警、安全加密与日志审计等核心功能,并通过MySQL数据库进行数据持久化,结合Qt实现图形化界面,支持高并发、数据脱敏、多平台对接与自动化部署。项目强调数据安全、隐私保护与系统可扩展性,适用于社区医疗、疾控中心、学校及医院等场景。; 适合人群:具备C++编程基础,熟悉数据库操作和基本软件工程流程的开发人员、计算机及相关专业学生、医疗信息化项目开发者,以及希望了解完整医疗管理系统开发流程的技术人员。; 使用场景及目标:①学习如何使用C++构建完整的医疗信息管理系统;②掌握数据库设计、前后端交互、权限控制、多线程处理和GUI开发等关键技术;③应用于社区卫生服务、学校健康管理、疾控数据统计等实际业务场景,提升儿童健康管理水平;④作为课程设计、毕业设计或实际项目的参考模板。; 阅读建议:建议读者结合文档中的代码示例与数据库脚本,搭建本地开发环境进行实践操作,重点关注系统架构设计、模块解耦、安全机制与前后端交互逻辑,深入理解各功能模块的实现原理,并尝试在此基础上进行功能扩展,如接入移动端或增加AI分析模块。

7,774

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧