pm

package
v0.18.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderNameValueDelimiter = ":"

	// Status is a virtual HTTP header. It looks like PHP returns HTTP status
	// information inside a virtual HTTP header named 'Status'.
	Status = "status"

	OldRelativeUrlMarker = `./`
	ForwardSlash         = `/`
)
View Source
const (
	ErrNoHeaderOnLine            = "no header on line: %v"
	ErrHeaderNameIsEmpty         = "header name is empty: %v"
	ErrHeaderValueIsEmpty        = "header value is empty: %v"
	ErrTooManyRelativeUrlMarkers = "too many relative URL markers: %v"
)
View Source
const (
	QueryParamExtraPath = "extrapath"
)

Variables

This section is empty.

Functions

func ExecPhpScript

func ExecPhpScript(client *cl.Client, requestId uint16, parameters []*nvpair.NameValuePair, stdin []byte) (stdOut []byte, stdErr []byte, err error)

ExecPhpScript executes a PHP script using the specified client. Path to the script file must be set as a 'SCRIPT_FILENAME' parameter inside the 'parameters' argument.

func ParseStatus

func ParseStatus(statusValue string) (statusCode uint, statusText string, err error)

ParseStatus parses information about HTTP status returned by PHP.

func RunOncePhpScript

func RunOncePhpScript(serverNetwork string, serverAddress string, requestId uint16, parameters []*nvpair.NameValuePair, stdin []byte) (stdOut []byte, stdErr []byte, err error)

RunOncePhpScript runs a PHP script once. Path to the script file must be set as a 'SCRIPT_FILENAME' parameter inside the 'parameters' argument.

func RunOnceSimplePhpScript

func RunOnceSimplePhpScript(serverNetwork string, serverAddress string, scriptFilePath string) (stdOut []byte, stdErr []byte, err error)

RunOnceSimplePhpScript runs a simple PHP script once and gets its output. Only the `SCRIPT_FILENAME` parameter is provided to the PHP script, that is why it is simple. The PHP-CGI server must be started manually before running this function.

Types

type Data

type Data struct {
	StatusCode uint
	StatusText string
	Headers    []*Header
	Body       []byte
}

Data is data returned by a PHP script.

func ExecPhpScriptAndGetHttpData

func ExecPhpScriptAndGetHttpData(client *cl.Client, requestId uint16, parameters []*nvpair.NameValuePair, stdin []byte) (data *Data, err error)

ExecPhpScriptAndGetHttpData executes a PHP script using the specified client, gets its output, splits the output into HTTP headers and HTTP body. Path to the script file must be set as a 'SCRIPT_FILENAME' parameter inside the 'parameters' argument. The PHP-CGI server must be started manually before running this function.

func RunOncePhpScriptAndGetHttpData

func RunOncePhpScriptAndGetHttpData(serverNetwork string, serverAddress string, requestId uint16, parameters []*nvpair.NameValuePair, stdin []byte) (data *Data, err error)

RunOncePhpScriptAndGetHttpData runs a PHP script once, gets its output, splits the output into HTTP headers and HTTP body. Path to the script file must be set as a 'SCRIPT_FILENAME' parameter inside the 'parameters' argument. The PHP-CGI server must be started manually before running this function.

func RunOnceSimplePhpScriptAndGetHttpData

func RunOnceSimplePhpScriptAndGetHttpData(serverNetwork string, serverAddress string, scriptFilePath string) (data *Data, err error)

RunOnceSimplePhpScriptAndGetHttpData runs a simple PHP script once, gets its output, splits the output into HTTP headers and HTTP body. Only the `SCRIPT_FILENAME` parameter is provided to the PHP script, that is why it is simple. The PHP-CGI server must be started manually before running this function.

func SplitHeadersFromStdout

func SplitHeadersFromStdout(stdout []byte) (data *Data, err error)

SplitHeadersFromStdout splits PHP stdout stream into HTTP headers and HTTP body.

func (*Data) FixLocationHeader added in v0.12.0

func (dta *Data) FixLocationHeader(currentUrlPath string) (err error)

FixLocationHeader fixes relative URLs in 'Location' HTTP headers. 'currentUrlPath' is the value of 'URL.Path' of the current request.

type Header struct {
	Name  string
	Value string
}

Header is an HTTP header returned by a PHP script.

func ParseHeader

func ParseHeader(line string) (hdr *Header, err error)

ParseHeader parses a PHP output line of text containing the HTTP header.

type OldSchoolStyleData added in v0.13.0

type OldSchoolStyleData struct {
	DocumentUri  string
	CgiExtraPath string
	QueryString  string
	RequestUri   string
}

type PhpScriptInfo added in v0.13.0

type PhpScriptInfo struct {
	// Paths in URL format,
	// i.e. with forward slashes.
	OriginalUrlPath string
	UrlRelPath      string
	UrlExtraPath    string

	// Paths in file system format,
	// i.e. with separators of an operating system.
	FilePath         string
	FileName         string
	FileExt          string
	FileAbsPath      string
	FileAbsExtraPath string

	// A special parameter for storing CGI extra path.
	// This parameter is used to move extra path from path to a query parameter
	// in order to make CGI requests compatible with modern HTTP standard.
	QueryParamExtraPath string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL