Unreal Web Server
Note: This page presents an overview of the Unreal Web Server and an explaination of what is a web server. If you're already familiar with these basic principles and want to get straight to the point, you can skip this page and go directly there.
Unreal Web Server
Unreal Web Server is a server allowing you to embed a web server in an Unreal Engine application, making it easy to write REST API for your games or applications. The following video shows some of the features enabled with Unreal Web Server, but the possibilities are endless.
Introduction to web servers
At the most basic level, whenever a browser needs a file hosted on a web server, the browser requests the file via HTTP. When the request reaches the HTTP server, it sends the requested document back, also through HTTP.
To fetch a web page, as we already said, your browser sends a request to the web server, which proceeds to search for the requested file in its own storage space. When the file is found, the server reads it, processes it, if required, and sends it to the browser. Let’s look at those steps in more details.
Hosting files
A web server first has to store the website’s files, namely all HTML documents and their related assets, including images, CSS stylesheets, JavaScript files, fonts, and videos.
Communicating through HTTP
Secondly, a web server provides support for HTTP (Hypertext Transfer Protocol). As its name implies it, HTTP specifies how to transfer hypertext (i, linked web documents) between two computers.
A protocol is a set of rules for the communication between two computers. HTTP is a textual, stateless protocol.
Textual
All commands are plain-text and human-readable.
Stateless
Neither the server nor the client remember the previous communications. For example, relying on HTTP alone, a server cannot remember a password you typed or what step you’re on in a transaction. You need an application server for tasks like that (we’ll cover that kind of technology in further articles).
HTTP provides clear rules on how a client and a server communicate:
Only clients can make HTTP requests, and then only to servers. Servers can only respond to a client’s HTTP request.
When requesting a file via HTTP, the clients must provide the file’s URL.
The web server must answer every HTTP request, at least with an error message.
On a web server, the HTTP server is responsible for processing and answering incoming requests.
When receiving a request, an HTTP server first checks whether the requested URL matches an existing file.
If so, the web server sends the file content back to the browser. If not, an application server builds the necessary file.
If neither process is possible, the web server returns an error message to the browser, most commonly “404 Not Found”.
Unreal Web Server features.
As we explained, just like a usual web server, UWS can serve static files: HTML files, CSS stylesheets, JavaScript files, fonts, and videos. You just have to specify the root folder of your files in the UWS startup configuration.
But the real power of UWS is its ability to communicate with Unreal Engine Blueprints. Thanks to this, UWS becomes a dynamic web server able to process the content and generate it on the fly from your games variables.