pm

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: MIT Imports: 12 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"
)
View Source
const (
	ErrNoHeaderOnLine     = "no header on line: %v"
	ErrHeaderNameIsEmpty  = "header name is empty: %v"
	ErrHeaderValueIsEmpty = "header value is empty: %v"
)

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.

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.

Jump to

Keyboard shortcuts

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