Skip to content

Built in HTTP server

Mohamed RACHID edited this page Feb 19, 2017 · 2 revisions

The built-in mini HTTP server is light and simple.

It provides a low-delay access to the latest data, as a JavaScript object or as a JSON object.

As it does not provide access to any file on your computer, there should be no safety issue by design.

It should be compliant enough with HTTP/1.0.

No virtual hosts are used. The specified host name in your browser does not matter to the HTTP server.

Configuration

Global HTTP server settings

The IP address

It is the address you want to bind the HTTP server to.

You can enter the IP address of an interface or special values local (IPv4 loopback 127.0.0.1), local6 (IPv6 loopback ::1) and any (all interfaces in IPv4 and IPv6).

Leaving this field empty is equivalent to any.

The Port

That is the port number. If you have a conflict, you can change it.

The Auto start

Check the box if you want the HTTP server to start when the program starts.

Per GPSD client settings

For every GPSD client in the program, you can set:

A Filename

This is the URI without the / prefix and without extension.

Of course, make sure that it is not duplicated with that of another GPSD client.

Examples:

  • default => http://localhost:42317/default.js or http://localhost/default.json
  • gps1/data => http://localhost:42317/gps1/data.js or http://localhost/gps1/data.json

An Expire delay

This is the delay before unrefreshed data become obsolete.

After this delay, the HTTP server will return a 504 Gateway Time-out status.

You can set it to 0.0 so that data never expire.

A JS function

If you do not want the JavaScript object alone, you can enter the name of the function to be called with the JavaScript object as an argument.

HTTP statuses

The HTTP status indicates what happened while treating a request.

The built-in HTTP server has a limited set of statuses. It should be complete enough though.

Set of statuses:

  • 200 OK - We have a success here!
  • 400 Bad Request - There is no way that the received request was a valid HTTP request.
  • 404 Not Found - The requested address is not valid, wrong path or wrong extension.
  • 405 Method Not Allowed - Only GET HTTP requests are accepted, sorry.
  • 503 Service Unavailable - The matching GPSD client is stopped.
  • 504 Gateway Time-out - Latest information has expired, or no information is available yet.

Recommendations

Well, running an HTTP server still suggests some recommendations:

  • Avoid giving public access to it, especially because output contains your location and because the program can crash!
  • Minimize the program in tray. This reduces the CPU usage.
  • Do not bind to all interfaces if you know that the loopback interface is enough.
  • Do not consider the built-in HTTP server as super strong, even though it is not weak.