The [WebServerRequest] class represents one incoming HTTP request. It also contains the proper helper methods for sending a response. The [WebServerRequest] class represents one incoming HTTP request. It also contains the proper helper methods for sending a response. Since HTML documents has a relatively fixed structure, this class contains head, body, footer properties, the response HTML can be added to these, and then these can be compiled and sent using [code]compile_body()[/code] or the [code]compile_and_send_body()[/code] helpers into the [code]compiled_body[/code] property. This adds an html5 type declaration then the opening [code]html[/code] tag, then the contents of the head variable to the [code]head[/code] section of the response, and then the contents of the body then footer variable into the [code]body[/code] section of the response, then it closes the main [code]html[/code] tag. It also contains helper methods for sending files, handling cookies, storing sessions, storing custom data etc. CSRF tokens are also supported. These are generated string tokens that are stored in HTTPSessions, but since they are universally needed, helper methods were added directly into [WebServerRequest]. They can be used to validate that a form was actually submitted by the user from a page rendered by the application's server itself, in order to mitigate attacks that use the technique called [C]ross [S]ite [R]equest [F]orgery. This framework uses a stack like url routing model, where the http path is split along forward slashes, and then these get handled going deeper into the given [WebServer]'s [WebNode] hierarchy, effectively using the node structure as a pseudo filesystem. Of course [WebNode]s can decide on handling the request's parameters themselves instead of letting the default hierarchy based routing to take place. For example [BrowsableFolderServeWebPage] uses this to implement a web based file browser. The currently handled segment can be queried using the [code]get_current_path_segment()[/code]. The [code]pop_path()[/code] and [code]push_path()[/code] helper methods can be used to switch segments. Returns true if the active [WebPermission] has create permission for this session. It you don't have a [WebPermission] set, all perissions are enabled for every user. Returns true if the active [WebPermission] has delete permission for this session. It you don't have a [WebPermission] set, all perissions are enabled for every user. Returns true if the active [WebPermission] has edit permission for this session. It you don't have a [WebPermission] set, all perissions are enabled for every user. Returns true if the active [WebPermission] has view permission for this session. It you don't have a [WebPermission] set, all perissions are enabled for every user. Calls [code]compile_body()[/code], and then [code]send()[/code]. Takes the head, body and footer properties, and merges them into the [code]compiled_body[/code] property. It adds an html5 type declaration, then the opening [code]html[/code] tag, then the contents of the [code]head[/code] property to the [code]head[/code] section of the response, and then the contents of the [code]body[/code] then footer property into the [code]body[/code] section of the response, then it closes the main [code]html[/code] tag. Note: You can override the default doctype declaration by setting the [code]"compiled_body_doctype_override"[/code] meta, the [code]html[/code] tag by setting the [code]"compiled_body_html_tag_override"[/code] meta, and the [code]body[/code] tag by setting the [code]"compiled_body_body_tag_override"[/code] meta using [code]set_meta()[/code]. Returns a custom HTTP response header or an empty String if it's not set. Returns whether a custom HTTP response header is set. Set a custom HTTP response header that will be sent to the client. Returns all the custom response headers that were previously set. Returns the value of the cookie [code]key[/code]. A helper method that tries to get the value of the [code]csrf_token[/code] key from the [HTTPSession] set into the [code]session[/code] property. Returns the currently active path segment. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current path segment is [code]b[/code], then this will return [code]b[/code]. If you reach the end, it will return an empty String! For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current path segment reached beyond [code]c[/code] (we are at the [WebNode] that has it's [code]uri_segment[/code] set to [code]c[/code]), then this will return empty String. Actually this is how [WebNode]s check whether they need to handle a request themselves or not ([code]if request.get_current_path_segment() == "/": handle_request(request)[/code]). Returns the index of the currently active path segment. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current path segment is [code]b[/code], then this will return 1. Returns how many files were in the http request. Note that only multipart forms can contain files. Returns the file as a PoolByteArray. Returns the file as a String. Return the file's name that was present in the form itself. Same as get_file_file_name at the moment. Returns the file's length. Returns the host which was present in the request header. Returns the request's method. Returns the next path segment. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current path segment is [code]b[/code], then this will return [code]c[/code]. Returns the value of the session property if it's not null, else it will try to create one using the active [HTTPSessionManager]. Returns the value that was set in the request header for the given key, or an empty String. Returns the path of the request, from the current path segment to the end. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], this will return "b/c/" using the it's default arguments. Returns the full path of the request. For example if you have [code]http://127.0.0.1/a/b/c[/code], this will return [code]a/b/c[/code]. Returns the i-th path segment. Returns how many path segments a request has. Returns how manny segments are remaining. Returns the owner [WebServer]. Returns the url up to the current segment prefixed with [code]/[/code]. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], this will return [code]/a/[/code]. Equivalent to [code]get_url_root() + add[/code]; Returns the url up to, including the current segment prefixed with [code]/[/code]. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], this will return [code]/a/b/[/code]. Returns the url up to, including the current segment - parent, prefixed and postfixed with [code]/[/code]. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], this will return [code]/a/[/code] using it's default arguments. Equivalent to [code]get_url_root_parent() + add[/code]; Returns the url up to, including the current segment prefixed with the host, with a [code]/[/code] at the end. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], this will return [code]http://127.0.0.1/a/b/[/code]. Equivalent to [code]get_url_site() + add[/code]; Returns the [WebServer]'s root [WebNode]. Returns whether the active session has a csrf token or not. Returns whether a file contained in the request has been moved or not. moves a file contained in the request to the specified destination. If the destionation file exists it will not be overwritten unless force is true. Returns the full http path. Mostly intended for internal use. [code]setup_url_stack()[/code] uses this. Moves the path stack pointer backward once. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], the current segment will become [code]a[/code]. Moves the path stack pointer forward once. For example if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]b[/code], the current segment will become [code]c[/code]. Note that if you have [code]http://127.0.0.1/a/b/c[/code], and the current segment is [code]c[/code], the current segment will become empty String. When you eventually send the response, the [WebServerCookie] added here will be added to the message header. If you want to get the receiver to delete a particular cookie, create a [WebServerCookie], add it, and use it's helper deletion related methods, which will end up adding commands to the header when the request is sent that that should (normally) cause the client to delete cookies. Returns a previously added [WebServerCookie]. If you want to access cookie strings that you previously sent to the client, use [code]get_cookie()[/code], this method is so that you can edit cookies before being sent further. Returns the [WebServerCookie] count. Removes a previously added [WebServerCookie]. If you want to remove a cookie from the client, see [code]response_add_cookie()[/code] and/or [code]response_remove_cookie_simple()[/code]. Helper method that adds a [WebServerCookie], which will ask client to delete the cookie denoted by [code]key[/code] after being sent. Sends the contents of the compiled_body property as a response. Sends an error. The default implementation calls the [WebServer]'s root [WebNode]'s [code]handle_error_send_request()[/code] method. Sends the file at the given path. Sends a redirect http header. Sets the pased csrf token to the active session, if there is one. The [WebServer] needs to call this when it finished parsing a http request header and setting up a [WebServerRequest]. It parses and sets up inbternals for the easy handling of http paths. A helper that validates the csrf token for you. Returns the currently active [WebPermission] or null. When you call [code]compile_body()[/code] or [code]compile_and_send_body()[/code], the contents of this property will end up in the [code]body[/code] portion of the resulting HTML. The contents of this property will be sent as response when you call send(). Normally you should use the [code]head[/code], [code]body[/code], and [code]footer[/code] properties along with [code]compile_body()[/code] or [code]compile_and_send_body()[/code], however you can use this directly when needed. The server might set this to true if the connection got closed while handling the request. It's not yet used. A shorthand property to set the Content-Type HTTP header. Equivalent to [code]custom_response_header_set("Content-Type", content_type)[/code] and [code]custom_response_header_get("Content-Type")[/code]. When you call [code]compile_body()[/code] or [code]compile_and_send_body()[/code], the contents of this property will end up in the bottom of the [code]body[/code] portion of the resulting HTML. When you call [code]compile_body()[/code] or [code]compile_and_send_body()[/code], the contents of this property will end up in the [code]head[/code] portion of the resulting HTML. The currently active permissions. This is updated every time a new WebPermission is activated while routing. Use this to access the active session for this [WebServerRequest]. If you want the session property to have a value, it has to be set manually somewhere along the line. Adding a [HTTPSessionManager] as a direct child of your [WebServer] and adding [SessionSetupWebServerMiddleware] to your [WebRoot] can do this for you automatically. The status code that the server will set in the response.