.
headers
: An associative array containing arbitrary headers to be included with the automatic response.
content_type
: The contents of the "Content-Type" header included with the automatic response. This cannot be set in the same filter as the headers. The MIME type and character set can be specified together (e.g. "text/plain; charset=utf-8")
.
You must define all of the folder content types for the folder to be correctly uploaded to the server. For example:
Code Block |
---|
mimeTypes = [{ext: ".html", content_type:"text/html;charset=utf-8"},{ext: ".js", content_type:"text/javascript;charset=utf-8"},{ext: ".css", content_type:"text/css;charset=utf-8"},{ext: ".png", content_type:"image/png"},{ext: ".otf", content_type:"font/otf"}]
server.AddGetFromFolder({ url_prefix: "/GetFolder", folder: "Example", filters: mimeTypes}) |
AddGetFromEvent(parameters As roAssociativeArray) As Boolean
Requests that an event of type roHttpEvent be sent to the configured message port. This occurs when an HTTP GET request is made for the specified URL path.
AddPostToString(parameters As roAssociativeArray) As Boolean
Requests that an event of type roHttpEvent be sent to the configured message port. This occurs when an HTTP POST request is made for the specified URL path. Use the roHttpEvent.GetRequestBodyString() method to retrieve the posted body.
AddPostToFile(parameters As roAssociativeArray) As Boolean
Requests that, when an HTTP POST request is made to the specified URL path, the request body be stored in a temporary file according to the parameters["destination_directory"]
value in the associative array. When this request is complete, an roHttpEvent event is sent to the configured message port. Use the roHttpEvent.GetRequestBodyFile() method to retrieve the name of the temporary file. If the file still exists at the time the response is sent, it will be automatically deleted. However, if the player reboots or loses power during the POST process, the file will not be deleted. For this reason, we recommend using a dedicated subdirectory as the "destination_directory"
and wiping this subdirectory during startup (using DeleteDirecotry()
) before adding handlers that refer to it.
AddPostToFormData(parameters As roAssociativeArray) As Boolean
Requests that, when an HTTP POST request is made to the specified URL path, an attempt be made to store form data (passed as application/x-www-form-urlencoded
or multipart/form-data
) in an associative array that can be retrieved by calling the roHttpEvent.GetFormData() method.
AddMethodFromEvent(parameters As roAssociativeArray) As Boolean
Requests that an event of type roHttpEvent be sent to the configured message port. Unlike AddGetFromEvent()
, this method can support arbitrary HTTP methods. The HTTP method is specified using the method member in the associative array.
AddMethodToFile(parameters As roAssociativeArray) As Boolean
Requests that, when an arbitrary HTTP request is made to the specified URL path, the request body be stored in a temporary file according to the parameters["destination_directory"]
value in the associative array. The HTTP method is specified using the method
member in the associative array. When the request is complete, an roHttpEvent event is sent to the configured message port. Use the roHttpEvent.GetRequestBodyFile() method to retrieve the name of the temporary file. If the file still exists at the time the response is sent, it will be automatically deleted.
AddMethodToString(parameters As roAssociativeArray) As Boolean
Attempts to support an arbitrary HTTP method. The request body is placed in a string and an event is raised. This makes the request body available via the roHttpEvent.GetRequestBodyString() method. A response can be sent in the same manner as the AddGetToEvent()
method.
SetupDWSLink(title As String) As Boolean
Generates a tab in the Diagnostic Web Server (DWS) that links directly to the base <ip_address:port> of the roHttpServer instance. The passed string specifies the title of the tab.
Example