libgpac
Documentation of the core library of GPAC
JSHTTPRequest Interface Reference

JSHTTPRequest API. More...

import"httpout.idl";

Public Member Functions

attribute void send ()
 
attribute DOMString body attribute signed long throttle (unsigned long long done, unsigned long long total)
 
attribute signed long read (ArrayBuffer buffer)
 
attribute void write (ArrayBuffer buffer)
 
attribute void close (unsigned long error)
 

Data Fields

attribute unsigned long reply
 
attribute readonly DOMString method
 
attribute readonly DOMString url
 
attribute readonly unsigned long auth_code
 
attribute readonly Array headers_in
 
attribute Array headers_out
 

Detailed Description

The JSHTTPRequest object provides an interface to the HTTP request being processed.

Member Function Documentation

◆ send()

attribute void JSHTTPRequest::send ( )

send the response to the request

+ Here is the caller graph for this function:

◆ throttle()

attribute DOMString body attribute signed long JSHTTPRequest::throttle ( unsigned long long  done,
unsigned long long  total 
)

reply body. It is undefined by default

  • if reply is 0, this can be set to a file path to serve. If not set, usual URL resolving of httpout is done
  • if reply is not 0, this can be set to a string containing the body. To deliver a binary file or a large file, use the read function

callback function used to throttle the download, can be used even if the request is handled by gpac. It is set to null by default

Parameters
doneamount of bytes already sent in request
totaltotal amount of bytes in request
Returns
a delay for next send in milliseconds

◆ read()

attribute signed long JSHTTPRequest::read ( ArrayBuffer  buffer)

callback function used to get data (GET requests). It is set to null by default

Parameters
bufferarray buffer to fill (shared array, do NOT keep)
Returns
the number of bytes read, negative value means no data available yet, 0 means end of file

◆ write()

attribute void JSHTTPRequest::write ( ArrayBuffer  buffer)

callback function used to receive data (PUT/POST requests). It is set to null by default

Parameters
bufferarray buffer received. If null, end of stream is reached

◆ close()

attribute void JSHTTPRequest::close ( unsigned long  error)

callback function used to monitor end of session. It is set to null by default

Parameters
errorGPAC error code for the session. If 1 (GF_EOS), the session is ended but underlying network is kept alive, otherwise session is destroyed

Field Documentation

◆ reply

attribute unsigned long JSHTTPRequest::reply

HTTP reply code to use. If 0, the request is handled by GPAC as usual. Otherwise, the request is handled by your script if the reply does not indicate an error

◆ method

attribute readonly DOMString JSHTTPRequest::method

HTTP method of the request

◆ url

attribute readonly DOMString JSHTTPRequest::url

HTTP URL of the request

◆ auth_code

attribute readonly unsigned long JSHTTPRequest::auth_code

Authentication reply code - requests are pre-identified using GPAC credentials: a value of 401 indicates no identification, 200 indicates identification OK, 403 indicates failure

◆ headers_in

attribute readonly Array JSHTTPRequest::headers_in

HTTP headers of the request, array of JSHTTPHeader objects

◆ headers_out

attribute Array JSHTTPRequest::headers_out

HTTP headers to set on the response, array of JSHTTPHeader objects (initialized as empty)