HTTP
Reference sheet for the HTTP service
The HTTP service simulates a basic web server. It has two modes of operation:
In “Fake” mode, requests to any URL will return a generic response with a configurable status code & headers. Supported file extensions (currently .html, .htm, .asp, .txt, .md, .js, .css)
will return a realistic body of that type, and unsupported file extensions will return the default html page.
In “Real” mode, a directory can be specified and the server will serve static files from that directory. If a requested file is not found, a 404 response will be returned.
Configuration
Section titled “Configuration”| Option | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Whether the HTTP service is enabled |
listen |
string | :80 |
The address and port to listen on (e.g. :80) |
status |
int | 200 |
The status code to return in “Fake” mode |
mode |
string | fake |
Which mode to use when serving files |
root_dir |
string | ./ |
Which directory to serve files from in “Real” mode |
To see instructions on how to configure these options, see the configuration guide.
Command
Section titled “Command”The HTTP service can be run on its own by passing it as a target to run:
gonetsim run httpgonetsim.exe run httpThis starts the HTTP service with the current configuration, without starting any other services (Including the HTTPS service; the HTTPS service is not started with this command).
Testing
Section titled “Testing”You can test the HTTP service using curl.
-
Start the HTTP service
Terminal window gonetsim run http -
In a separate terminal, make a request to the service using
curlTerminal window curl http://localhost -
Return to the GoNetSim instance and you should see a log of the request in the output
Further reading
Section titled “Further reading”- See the configuration guide for a walkthrough on configuration
- See the HTTPS reference sheet for information on the HTTPS service
