---
title: "Http响应协议"
author: "olikeit"
date: "2013-04-16T21:47:12Z"
tags: []
categories: ["互联网"]
slug: "http"
draft: false
lastmod: "2013-04-14T21:11:56Z"
id: 1847295
url: "https://olikeit.iteye.com/blog/1847295"
---

# 响应协议

 

## 1　响应信息

 

```
// 响应首行
HTTP/1.1 200 OK
// 响应头信息
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Content-Length: 777
Date: Sat, 09 Feb 2012 18:30:52 GMT
// 空行，下面是响应正文，即HTML代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="http://localhost:80/hello/">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    This is my JSP page. <br>
    
    <form method="post" action="index.jsp">
    	<input type="text" name="username" /><br/>
    	<input type="submit" value="SUBMIT"/>
    </form>
  </body>
</html>
```

 

 

 

l HTTP/1.1 200 OK：响应协议为HTTP1.1，状态码为200，表示请求成功，OK是对状态码的解释；

 

l Server: Apache-Coyote/1.1：这是服务器的版本信息；

 

l Content-Type: text/html;charset=UTF-8：请求正文使用的编码为UTF-8；

 

l Content-Length: 777：响应的内容为777字节；

 

l Set-Cookie: JSESSIONID=C97E2B4C55553EAB46079A4F263435A4; Path=/hello：响应给客户端的Cookie；

 

l Date: Sat, 09 Feb 2012 18:30:52 GMT：响应的时间这个时间是美国时间，这可能会有8小时的时区差；

 

 

 

常见状态码：

 

l 404 not found：没有找到；

 

l 500 error：找到了，但内部出错；

 

l 200 ok：成功！

&lt;!--EndFragment--&gt;

&lt;!--EndFragment--&gt;