Black Lives Matter. Support the Equal Justice Initiative.

Package cgi

import "net/http/cgi"
Overview
Index

Overview ▾

包cgi实现RFC 3875中指定的CGI(通用网关接口).

请注意,使用CGI意味着启动一个新进程来处理每个请求,这通常比使用长时间运行的服务器效率低. 该软件包主要用于与现有系统兼容.

func Request

func Request() (*http.Request, error)

请求返回当前环境中表示的HTTP请求. 假定当前程序由CGI环境中的Web服务器运行. 如果适用,将填充返回的请求的正文.

func RequestFromMap

func RequestFromMap(params map[string]string) (*http.Request, error)

RequestFromMap从CGI变量创建一个http.Request. 返回的"请求的正文"字段未填充.

func Serve

func Serve(handler http.Handler) error

服务在当前活动的CGI请求(如果有)上执行提供的Handler. 如果当前没有CGI环境,则返回错误. 提供的处理程序可能无法使用http.DefaultServeMux.

type Handler

处理程序在具有CGI环境的子进程中运行可执行文件.

type Handler struct {
    Path string // path to the CGI executable
    Root string // root URI prefix of handler or empty for "/"

    // Dir specifies the CGI executable's working directory.
    // If Dir is empty, the base directory of Path is used.
    // If Path has no base directory, the current working
    // directory is used.
    Dir string

    Env        []string    // extra environment variables to set, if any, as "key=value"
    InheritEnv []string    // environment variables to inherit from host, as "key"
    Logger     *log.Logger // optional log for errors or nil to use log.Print
    Args       []string    // optional arguments to pass to child process
    Stderr     io.Writer   // optional stderr for the child process; nil means os.Stderr; added in Go 1.7

    // PathLocationHandler specifies the root http Handler that
    // should handle internal redirects when the CGI process
    // returns a Location header value starting with a "/", as
    // specified in RFC 3875 § 6.3.2. This will likely be
    // http.DefaultServeMux.
    //
    // If nil, a CGI response with a local URI path is instead sent
    // back to the client and not redirected internally.
    PathLocationHandler http.Handler
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

by  ICOPY.SITE