首页
社区
课程
招聘
[原创]HTTP/1.1协议格式头
发表于: 2012-12-4 18:20 4944

[原创]HTTP/1.1协议格式头

2012-12-4 18:20
4944
近日在学习HTTP协议,没有找到比较直观HTTP/1.1协议格式头,于是自己下载HTTP/1.1协议文档整理了一份,放在这里当个网盘,欢迎大家指出错误和批评。
版权声明:对此文章删除和编辑的权利归本ID所有。

通用头格式
struct general_header
{
    char_ptr cache_control;
    char_ptr connection;
    char_ptr date;
    char_ptr pragma;
    char_ptr trailer;
    char_ptr transfer_encoding;
    char_ptr upgrade;
    char_ptr via;
    char_ptr warning;
};
typedef general_header* general_header_ptr;
struct entity_header
{
    char_ptr allow;
    char_ptr content_encoding;
    char_ptr content_language;
    char_ptr content_length;
    char_ptr content_location;
    char_ptr content_md5;
    char_ptr content_range;
    char_ptr content_type;
    char_ptr expires;
    char_ptr last_modified;
};
typedef entity_header* entity_header_ptr;

HTTP请求格式
/**
request =
{
    request_line
    general_header
    request_header
    entity_header
    CRLFCRLF
    message_body
**/
struct request_header
{
    char_ptr request_line;
    general_header general;
    char_ptr accept;
    char_ptr accept_charset;
    char_ptr accept_encoding;
    char_ptr accept_language;
    char_ptr authorization;
    char_ptr expect;
    char_ptr from;
    char_ptr host;
    char_ptr if_match;
    char_ptr if_modified_since;
    char_ptr if_none_match;
    char_ptr if_range;
    char_ptr if_unmodified_since;
    char_ptr max_forwards;
    char_ptr proxy_authorization;
    char_ptr range;
    char_ptr referer;
    char_ptr te;
    char_ptr user_agent;
    entity_header entity;
    char request_header_end[4];
    char_ptr message_body;
    char_ptr body_length;
};
typedef request_header* request_header_ptr;

HTTP回答格式
/**
response =
{
    status_line
    general_header
    response_header
    entity_header
    CRLFCRLF
    message_body
}
**/
struct response_header
{
    char_ptr status_line;
    general_header general;
    char_ptr accept_ranges;
    char_ptr age;
    char_ptr etag;
    char_ptr location;
    char_ptr proxy_authenticate;
    char_ptr retry_after;
    char_ptr server;
    char_ptr vary;
    char_ptr www_authenticate;
    entity_header entity;
    char response_header_end[4];
    char_ptr message_body;
    char_ptr body_length;
};
typedef response_header* response_header_ptr;

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 107
活跃值: (399)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
也不放个应用实例??????????
2012-12-4 18:41
0
雪    币: 304
活跃值: (25)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
最近也有用到,多谢LZ!
2012-12-4 23:26
0
雪    币: 148
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
Request URL:http://bbs.pediy.com/showthread.php?t=159485
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:bbs.pediy.com
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11

额,这叫啥呢?http请求头?楼主能解释下您的代码啥意思吗,俺是小白,希望楼主给俺个希望
2012-12-5 00:20
0
游客
登录 | 注册 方可回帖
返回
//