wsgi的environ变量
The environ dictionary is required to contain these CGI environment variables, as defined by the Common Gateway Interface specification
The following variables must be present(存在), unless their value would be an empty string, in which case they may be omitted(省略), except as otherwise noted below.
REQUEST_METHOD(请求方法)
The HTTP request method, such as "GET" or "POST". This cannot ever be an empty string, and so is always required.
SCRIPT_NAME
The initial portion of the request URL’s “path” that corresponds to the application object, so that the application knows its virtual “location”.
This may be an empty string, if the application corresponds to the “root” of the server.
PATH_INFO(请求的地址)
The remainder of the request URL’s “path”, designating the virtual “location” of the request’s target within the application.
This may be an empty string, if the request URL targets the application root and does not have a trailing slash.
QUERY_STRING(URL中传递的参数)
The portion of the request URL that follows the "?", if any. May be empty or absent.
CONTENT_TYPE
The contents of any Content-Type fields in the HTTP request. May be empty or absent.
CONTENT_LENGTH
The contents of any Content-Length fields in the HTTP request. May be empty or absent.
SERVER_NAME, SERVER_PORT
When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL.
Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL.
See the URL Reconstruction section below for more detail.
SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required.(SERVER_NAME和SERVER_PORT永远不能是空字符串,因此总是必需的)
SERVER_PROTOCOL
The version of the protocol the client used to send the request. Typically this will be something like
"HTTP/1.0" or "HTTP/1.1" and may be used by the application to determine how to treat any HTTP request headers.
(This variable should probably be called REQUEST_PROTOCOL, since it denotes the protocol used in the request, and is not necessarily the protocol that will be used in the server’s response.
However, for compatibility with CGI we have to keep the existing name.
因为它表示在请求中使用的协议,而不一定是将在服务器响应中使用的协议。但是,为了与CGI兼容,我们必须保留现有的名称)
HTTP_ Variables
Variables corresponding to the client-supplied HTTP request headers (i.e., variables whose names begin with "HTTP_").
The presence or absence of these variables should correspond with the presence or absence of the appropriate HTTP header in the request.
A server or gateway should attempt to provide as many other CGI variables as are applicable.
In addition, if SSL is in use, the server or gateway should also provide as many of the Apache SSL environment variables as are applicable, such as HTTPS=on and SSL_PROTOCOL.
Note, however, that an application that uses any CGI variables other than the ones listed above are necessarily non-portable to web servers that do not support the relevant extensions. (For example, web servers that do not publish files will not be able to provide a meaningful DOCUMENT_ROOT or PATH_TRANSLATED.)
A WSGI-compliant server or gateway should document what variables it provides, along with their definitions as appropriate. Applications should check for the presence of any variables they require, and have a fallback plan in the event such a variable is absent.
Note: missing variables (such as REMOTE_USER when no authentication has occurred) should be left out of the
environ dictionary. Also note that CGI-defined variables must be strings, if they are present at all. It is a violation of this specification for a CGI variable’s value to be of any type other than str.
注意:应该将遗漏的变量(如未发生身份验证时的REMOTE_USER)从环境字典中删除。还请注意,如果存在的话,cgi定义的变量必须是字符串。将CGI变量的值设置为str以外的任何类型都是违反此规范的
In addition to the CGI-defined variables, the environ dictionary may also contain arbitrary operating-system “environment variables”, and must contain the following WSGI-defined variables:
除了cgi定义的变量外,环境字典还可以包含任意操作系统的“环境变量”,并且必须包含以下wsgi定义的变量:
wsgi.version
The tuple (1, 0), representing WSGI version 1.0.
wsgi.url_scheme
A string representing the “scheme” portion of the URL at which the application is being invoked. Normally, this will have the value "http" or "https", as appropriate.
wsgi.input
An input stream (file-like object) from which the HTTP request body can be read. (The server or gateway may perform reads on-demand as requested by the application, or it may pre- read the client’s request body and buffer it in-memory or on disk, or use any other technique for providing such an input stream, according to its preference.)
wsgi.errors
An output stream (file-like object) to which error output can be written, for the purpose of recording program or other errors in a standardized and possibly centralized location. This should be a “text mode” stream; i.e., applications should
use "n" as a line ending, and assume that it will be converted to the correct line ending by the server/gateway.
For many servers, wsgi.errors will be the server’s main error log. Alternatively, this may be
sys.stderr, or a log file of some sort. The server’s documentation should include an explanation of how to configure this or where to find the recorded output. A server or gateway may supply different error streams to different
applications, if this is desired.
wsgi.multithread
This value should evaluate true if the application object may be simultaneously invoked by another thread in the same process, and should evaluate false otherwise.
wsgi.multiprocess
This value should evaluate true if an equivalent application object may be simultaneously invoked by another process, and should evaluate false otherwise.
wsgi.run_once
This value should evaluate true if the server or gateway expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a gateway based on CGI (or something similar).
Finally, the environ dictionary may also contain server-defined variables. These variables should be named using only lower-case letters, numbers, dots, and underscores, and should be prefixed with a name that is unique to the defining server or gateway. For example, mod_python might define variables with names like mod_python.some_variable.
转载 http://blog.360converter.com/archives/1024
wsgi的environ变量的更多相关文章
- WSGI的理解
Python web开发中,服务端程序可分为2个部分: 服务器程序(用来接收.整理客户端发送的请求) 应用程序(处理服务器程序传递过来的请求) 在开发应用程序的时候,我们会把常用的功能封装起来,成为各 ...
- WSGI框架及Paste+Pastedeploy+route+webob开发
一.前言 WSGI服务器 一个Web服务器网关接口 (WSGI)服务器实现了WSGI接口的Web服务器端运行的Python的Web应用程序. 为什么需要WSGI? 传统的Web服务器不理解或有任何方式 ...
- Flask学习-Flask基础之WSGI
一.WSGI为什么会出现? 在学习一个东西之前,我们肯定想知道:它为什么会出现?那么,WSGI为什么会出现呢? 我们知道,部署一个web应用,经常需要使用nginx.apache或者IIS等web服务 ...
- WSGI剖析
在一个 HTTP 请求到达服务器时, 服务器接收并调用 web 应用程序解析请求, 产生响应数据并返回给服务器. 这里涉及了两个方面的东西: 服务器(server)和应用程序(application) ...
- [Python WEB开发] 使用WSGI开发类Flask框架 (二)
WSGI Web服务器网关接口 WSGI主要规定了Web服务器如何与Web应用程序进行通信,以及如何将Web应用程序链接在一起来处理一个请求. wsgiref Python中的WSGI参考模块 ...
- 【Python Programe】WSGI (Web Server Gateway Interface)
Part1: What is a Web server? 一个位于物理服务器上的网络服务器(服务器里的服务器),等待客户端去发送request,当服务器接收到request,就会生成一个respons ...
- django基础一:web、wsgi、mvc、mtv
一.web框架 web框架,即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以快速开发特定的系统.他山之石,可以攻玉.python的所有web框架,都是对so ...
- python wsgi PEP333 中文翻译
PEP 333 中文翻译 首先说明一下,本人不是专门翻译的,英文水平也不敢拿来献丑.只是这是两年前用python的时候为了自己学习方便而翻译的,记录着笔记自己看看而已.最近翻出来看看觉得还是放出来吧. ...
- wsgi pep333
转自:https://www.aliyun.com/jiaocheng/444966.html?spm=5176.100033.1.11.559a7C 摘要:wsgi介绍参考:pep333wsgi有两 ...
随机推荐
- Django学习路19_is_delete属性,重写类方法,显性隐性属性
如果在 创建数据表时,使用了 objects = models.Model() 使隐形属性变为了 显性属性 则 必须要自己定义一个 继承了 models.Model 类的类,实现 管理功能 如果一个属 ...
- MySQL选错索引导致的线上慢查询事故
前言 又和大家见面了!又两周过去了,我的云笔记里又多了几篇写了一半的文章草稿.有的是因为质量没有达到预期还准备再加点内容,有的则完全是一个灵感而已,内容完全木有.羡慕很多大佬们,一周能产出五六篇文章, ...
- async和await的使用总结 ~ 竟然一直用错了c#中的async和await的使用。。
对于c#中的async和await的使用,没想到我一直竟然都有一个错误.. ..还是总结太少,这里记录下. 这里以做早餐为例 流程如下: 倒一杯咖啡. 加热平底锅,然后煎两个鸡蛋. 煎三片培根. 烤两 ...
- 非常适合小白的 Asyncio 教程
非常适合小白的 Asyncio 教程 原文:https://segmentfault.com/a/1190000008814676 所谓「异步 IO」,就是你发起一个 IO 操作,却不用等它结束, ...
- 如何简单理解spring aop和事务
用比喻的方法理解吧: 初学者的理解,仅仅为了个人好记 aop:由三部分组成:工具箱,工人,为工人分配工具 tx事务:由四部分组成:管理者,制度,工人,向工人通知管理制度 为什么这样理解呢?个人觉得好 ...
- maven项目的运行方式,maven私服的上传下载
一.maven项目父子工程的运行方式 1.通过父项目的plugin下集成的tomacat run启动 2.通过自身项目的tomcat plugin启动,但前提是所依赖的项目必须全部都install(将 ...
- Chrome划词翻译-Saladict
Saladict 沙拉查词是一款专业划词翻译扩展,为交叉阅读而生.大量权威词典涵盖中英日韩法德西语,支持复杂的 划词操作.网页翻译.生词本.PDF,以及 Vimium 全键盘操作 . 迄今为止最好用的 ...
- hashCode竟然不是根据对象内存地址生成的?还对内存泄漏与偏向锁有影响?
起因 起因是群里的一位童鞋突然问了这么问题: 如果重写 equals 不重写 hashcode 会有什么影响? 这个问题从上午10:45 开始陆续讨论,到下午15:39 接近尾声 (忽略这形同虚设的马 ...
- SkyWalking APM8.1.0 搭建与项目集成使用
SkyWalking介绍 SkyWalking是什么? SkyWalking是一个可观测性分析平台和应用性能管理系统,提供分布式跟踪.服务网格遥测分析.度量聚合和可视化一体化解决方案,并支持多种开发语 ...
- HTML5 plus是什么?
1.HTML5 plus 1.1 提出问题 如果大家使用过MUI框架,看到下面的代码就不会感到陌生. mui.plusReady(function(){ var self = plus.webview ...