web.server

web.server

web.server

Function

Read request and server information.

Syntax

Parameters

No parameters.

Return value

TypeDescription
ObjectReturns the current HTTP request and connection information object.

Object structure

FieldTypeDescription
methodStringThe current request method, usually an uppercase string such as GET, POST, PUT, DELETE, etc.
versionStringHTTP protocol version debugging text, such as HTTP/1.1, HTTP/2.0.
schemeStringRequest protocol, usually http or https.
headersObjectRequest header object; the key is the request header name, and the value is the request header string value.
local_addrStringServer local listening address, including IP and port.
remote_addrStringClient remote address, including IP and port.
ipString/NullClient IP string; returns null if the underlying request cannot resolve the IP.
portInt/NullClient port; returns null if the underlying request cannot resolve the port.

Example

Read the request header and client address:

Notes

  • web.method and web.server.method return the same request method string.
  • The headers field only reads client request headers; please use web.header() to set response headers.
  • The request header name is generated by the underlying HTTP service, and should be based on the actual object key name before accessing.