tringBuilder response =new StringBuilder();
//1) HTTP协议版本、状态代码、描述
response.append("HTTP/1.1").append(BLANK).append("200").append(BLANK).append("OK").append(CRLF);
//2) 响应头(Response Head)
response.append("Server:bjsxt Server/0.0.1").append(CRLF);
response.append("Date:").append(new Date()).append(CRLF);
response.append("Content-type:text/html;charset=GBK").append(CRLF);
//正文长度 :字节长度
response.append("Content-Length:").append(responseContext.toString().getBytes().length).append(CRLF);
//3)正文之前
response.append(CRLF);
//4)正文
response.append(responseContext); System.out.println(responseContext);

先上代码,和结果。执行程序,浏览器中输入localhost:8088

控制台的结果是

GET / HTTP/1.1
Host: localhost:8088
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8 HTTP/1.1 200 OK
Server: tomcat
DateSun Nov 09 20:42:08 CST 2014
Content-type:text/html;charset=GBK
Content-Length:89 <html><head><titilt>你怎么舍得我难过</title>大姑娘美,大姑娘浪</head><body></body></html>

  

最新文章

  1. [Leetcode]String to Integer (atoi) 简易实现方法
  2. 性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework
  3. NFV技术中遇到的新名词
  4. 分享:大晚上用自己的锤子手机跨系统刷MIUI,跌宕起伏啊!!
  5. Angular学习(4)- 数组双向梆定
  6. Android框架 加载图片 库 Picasso 的使用简介
  7. wifi详解(三)
  8. poj 2679 Adventurous Driving(SPFA 负环)
  9. HFS - 简单的将个人电脑变服务器!
  10. 简单好用的Adapter---ArrayAdapter
  11. apache 安装mod_rewrite
  12. SQL作业二
  13. Ubuntu下 MySql忘记密码解决方案
  14. C - Heavy Transportation &amp;&amp; B - Frogger(迪杰斯变形)
  15. MVC中的下载文件及上传
  16. Linux 问题
  17. SQL server 导出平面文件时出错: The code page on Destination - 3_txt.Inputs[Flat File Destination Input].Columns[UserId] is 936 and is required to be 1252.
  18. python基础一 ------可迭代类型的连接
  19. Linux From Scratch [3]
  20. 搭建spark集群

热门文章

  1. Rust入门篇 (1)
  2. [转载]mongoDB学习笔记——存取图片(C#)
  3. Android支付接入(三):电信爱游戏支付
  4. IIC驱动分析
  5. 学点PYTHON基础的东东--数据结构,算法,设计模式---观察者模式
  6. IText 生成横向的doc文档
  7. navicat 导入sql文件乱码问题解决
  8. Eclipse 安装FindBugs插件
  9. BCB6编译LUA5.15成功!
  10. vmware tools安装程序无法继续,Microsoft Runtime DLL安装程序未能完成安装。的解决方法