class BaseHTTPRequestHandler(socketserver.StreamRequestHandler)

HTTP request handler base class.
 |  
 |  The following explanation of HTTP serves to guide you through the
 |  code as well as to expose any misunderstandings I may have about
 |  HTTP (so you don't need to read the code to figure out I'm wrong
 |  :-).
 |  
 |  HTTP (HyperText Transfer Protocol) is an extensible protocol on
 |  top of a reliable stream transport (e.g. TCP/IP).  The protocol
 |  recognizes three parts to a request:
 |  
 |  1. One line identifying the request type and path
 |  2. An optional set of RFC-822-style headers
 |  3. An optional data part
 |  
 |  The headers and data are separated by a blank line.
 |  
 |  The first line of the request has the form
 |  
 |  <command> <path> <version>
 |  
 |  where <command> is a (case-sensitive) keyword such as GET or POST,
 |  <path> is a string containing path information for the request,
 |  and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
 |  <path> is encoded using the URL encoding scheme (using %xx to signify
 |  the ASCII character with hex code xx).
 |  
 |  The specification specifies that lines are separated by CRLF but
 |  for compatibility with the widest range of clients recommends
 |  servers also handle LF.  Similarly, whitespace in the request line
 |  is treated sensibly (allowing multiple spaces between components
 |  and allowing trailing whitespace).
 |  
 |  Similarly, for output, lines ought to be separated by CRLF pairs
 |  but most clients grok LF characters just fine.
 |  
 |  If the first line of the request has the form

|  <command> <path>
 |  
 |  (i.e. <version> is left out) then this is assumed to be an HTTP
 |  0.9 request; this form has no optional headers and data part and
 |  the reply consists of just the data.
 |  
 |  The reply form of the HTTP 1.x protocol again has three parts:
 |  
 |  1. One line giving the response code
 |  2. An optional set of RFC-822-style headers
 |  3. The data
 |  
 |  Again, the headers and data are separated by a blank line.
 |  
 |  The response code line has the form
 |  
 |  <version> <responsecode> <responsestring>
 |  
 |  where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
 |  <responsecode> is a 3-digit response code indicating success or
 |  failure of the request, and <responsestring> is an optional
 |  human-readable string explaining what the response code means.
 |  
 |  This server parses the request and the headers, and then calls a
 |  function specific to the request type (<command>).  Specifically,
 |  a request SPAM will be handled by a method do_SPAM().  If no
 |  such method exists the server sends an error response to the
 |  client.  If it exists, it is called with no arguments:
 |  
 |  do_SPAM()
 |  
 |  Note that the request name is case sensitive (i.e. SPAM and spam
 |  are different requests).
 
 |  The various request details are stored in instance variables:
 |  
 |  - client_address is the client IP address in the form (host,
 |  port);
 |  
 |  - command, path and version are the broken-down request line;
 |  
 |  - headers is an instance of email.message.Message (or a derived
 |  class) containing the header information;
 |  
 |  - rfile is a file object open for reading positioned at the
 |  start of the optional input data part;
 |  
 |  - wfile is a file object open for writing.
 |  
 |  IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!
 |  
 |  The first thing to be written must be the response line.  Then
 |  follow 0 or more header lines, then a blank line, and then the
 |  actual data (if any).  The meaning of the header lines depends on
 |  the command executed by the server; in most cases, when data is
 |  returned, there should be at least one header line of the form
 |  
 |  Content-type: <type>/<subtype>
 |  
 |  where <type> and <subtype> should be registered MIME types,
 |  e.g. "text/html" or "text/plain".
 |  
 |  Method resolution order:
 |      BaseHTTPRequestHandler
 |      socketserver.StreamRequestHandler
 |      socketserver.BaseRequestHandler
 |      builtins.object

Python——Baseequestandler class (Interesting found in python‘s document)的更多相关文章

  1. python之路(sed,函数,三元运算)

    python之路(sed,函数,三元运算) 一.sed集合 1.set无序,不重复序列 2.创建 se = {11,22,33,33,44} list() #只要是一个类加上()自动执行 list _ ...

  2. 趣闻|Python之禅(The Zen of Python)

    在Python解释器中输入“import this”会发生什么?如果你不知道这个彩蛋,推荐继续阅读这篇文章. 2001年秋,Foretec(一家会议组织公司)正在准备召开第十届Internationa ...

  3. python bottle框架(WEB开发、运维开发)教程

    教程目录 一:python基础(略,基础还是自己看书学吧) 二:bottle基础 python bottle web框架简介 python bottle 框架环境安装 python bottle 框架 ...

  4. python笔记六(函数的参数、返回值)

    一 调用函数 在写函数之前,我们先尝试调用现有的函数 >>> abs(-9) 9 除此之外,还有我们之前使用的len()等.可以用于数据类型转换的 int() float() str ...

  5. Python协程(真才实学,想学的进来)

    真正有知识的人的成长过程,就像麦穗的成长过程:麦穗空的时候,麦子长得很快,麦穗骄傲地高高昂起,但是,麦穗成熟饱满时,它们开始谦虚,垂下麦芒. --蒙田<蒙田随笔全集> *** 上篇论述了关 ...

  6. Python实现HMM(隐马尔可夫模型)

    1. 前言 隐马尔科夫HMM模型是一类重要的机器学习方法,其主要用于序列数据的分析,广泛应用于语音识别.文本翻译.序列预测.中文分词等多个领域.虽然近年来,由于RNN等深度学习方法的发展,HMM模型逐 ...

  7. python基础——13(系统、时间、序列化模块)

    一.时间模块 1.标准库time %y 两位数的年份表示(00-99) %Y 四位数的年份表示(0000-9999) %m 月份(01-12) %d 月中的一天(0-31) %H 24小时制小时数(0 ...

  8. 以股票RSI指标为例,学习Python发送邮件功能(含RSI指标确定卖点策略)

    本人之前写过若干“给程序员加财商”的系列文,目的是通过股票案例讲述Python知识点,让大家在学习Python的同时还能掌握相关的股票知识,所谓一举两得. 在之前的系列文里,大家能看到K线,均线,成交 ...

  9. 12、Python函数高级(命名空间、作用域、装饰器)

    一.名称空间和作用域 1.命名空间(Namespace) 命名空间是从名称到对象的映射,大部分的命名空间都是通过 Python 字典来实现的. 命名空间提供了在项目中避免名字冲突的一种方法.各个命名空 ...

随机推荐

  1. win32 sdk列表视图控件(ListCtrl或ListView)资料整理

    列表视图控件是一种非常常用的控件,在需要以报表形式显示数据时,列表控件通常是最好的选择,许多专用的数据报表控件,也是在它的基础上派生而来.与树视图类似,列表控件可以由多个子项目组成,可以设置为Icon ...

  2. mysql的expain(zz)

    两张表,T1和T2,都只有一个字段,id int.各插入1000条记录,运行如下语句: explain SELECT t1.id,t2.id FROM t1 INNER JOIN t2 ON t1.i ...

  3. poj 2826(好坑,线段相交问题)

    An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11576   Accepted: 176 ...

  4. validate+jquery+ajax表单验证

    1.案例 1.1 Html form表单内容 <form class="cForm" id="cForm" method="post" ...

  5. (13)python 正则表达式

    匹配单个字符 f. o    f和o之间是任意字符   例如:fbo123 .. 任意两个字符 \.用来匹配. 边界匹配 the     表示包含the的任何字符串 ^from 表示以from开头的所 ...

  6. 有向图强连通分量的Tarjan算法及模板

    [有向图强连通分量] 在有向图G中,如果两个顶点间至少存在一条路径,称两个顶点强联通(strongly connected),如果有向图G的每两个顶点都强联通,称有向图G是一个强联通图.非强联通图有向 ...

  7. python判断一个数是否是2的几次幂

    判断一个数是不是2的几次幂,最简单粗暴的做法就是直接迭代除以2,这里有一个更好的方法,那就是采用位运算. 我们观察下面属于2的几次幂的数的变化规律,用2进制表示. 十进制 二进制 0 0 2 10 4 ...

  8. luogu P1038借教室【Noip提高组2012】

    这道题我读完题目的第一感觉是: 这不就是个线段树??用线段树维护区间最小值,检查是否满足订单要求即可判断. 对于修改操作直接在区间上进行. 据说会卡一卡线段树,但是貌似写一个懒标记,连zkw线段树都不 ...

  9. 差分+树状数组 线段树【P2357】 守墓人

    题目描述-->p2357 守墓人 敲了一遍线段树,水过. 树状数组分析 主要思路: 差分 简单介绍一下差分(详细概念太麻烦,看下面. 给定一个数组 7 8 6 5 1 8 18 20 35 // ...

  10. bit & byte & B & KB & Kbps & KBps & ps

    存储单位bit & byte & B & KB & Kbps & KBps & ps    (bit,位:byte,字节:区别) Bit,位 :二进制数 ...