Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MgConnection

Index

Constructors

constructor

Accessors

requestInfo

  • Return information associated with the request. Use this function to implement a server and get data about a request from a HTTP/HTTPS client. Note: Before CivetWeb 1.10, this function could be used to read a response from a server, when implementing a client, although the values were never returned in appropriate mg_request_info elements. It is strongly advised to use mg_get_response_info for clients.

    Returns MgRequestInfo

requestLink

  • get requestLink(): string
  • Get a formatted link corresponding to the current request

    Returns string

responseInfo

  • Return information associated with a HTTP/HTTPS response. Use this function in a client, to check the response from the server.

    Returns MgResponseInfo

Methods

getCookie

  • getCookie(cookieName: string): string
  • Returns the cookie value string that matches the cookie name

    Parameters

    • cookieName: string

      cookie name to get the value from

    Returns string

    cookie value

getHeader

  • getHeader(headerName: string): string
  • Parameters

    • headerName: string

      header name to get the value from

    Returns string

    header value

getParam

  • getParam(name: string, occurence?: number): string
  • Returns a query which contained in the supplied buffer. The occurrence value is a zero-based index of a particular key name. This should not be confused with the index over all of the keys. Note that this function assumes that parameters are sent as text in http query string format, which is the default for web forms. This function will work for html forms with method="GET" and method="POST" attributes. In other cases, you may use a getParam version that directly takes the data instead of the connection as a first argument.

    Parameters

    • name: string

      the key to search for

    • Optional occurence: number

    Returns string

    parameter value

getPostData

  • getPostData(): string
  • Returns response body from a request made as POST. Since the connections map is protected, it can't be directly accessed. This uses string to store post data to handle big posts.

    Returns string

    Post data

read

  • read(len: number): [string, number]
  • Read data from the remote end, return number of bytes read.

    Parameters

    • len: number

    Returns [string, number]

    connection has been closed by peer. No more data could be read.

websocketClientWrite

  • Send data to a websocket server wrapped in a masked websocket frame. Uses mg_lock_connection to ensure that the transmission is not interrupted, i.e., when the application is proactively communicating and responding to a request simultaneously.

    Send data to a websocket erver wrapped in a websocket frame. This function is available when civetweb is compiled with -DUSE_WEBSOCKET

    Call is blocking.

    Parameters

    Returns number

    0 when the connection has been closed

websocketWrite

  • Send data to a websocket client wrapped in a websocket frame. Uses mg_lock_connection to ensure that the transmission is not interrupted, i.e., when the application is proactively communicating and responding to a request simultaneously.

    Send data to a websocket client wrapped in a websocket frame. This function is available when civetweb is compiled with -DUSE_WEBSOCKET

    Call is blocking.

    Parameters

    Returns number

    0 when the connection has been closed

write

  • write(data: string): number
  • Send data to the client.

    Call is blocking

    Parameters

    • data: string

    Returns number

    0 when the connection has been closed

Generated using TypeDoc