Here we provide a concise summary of the TritonHTTP spec. You should read the spec doc for more details and clarifications.
TritonHTTP follows the general HTTP message format. And it has some further specifications:
- HTTP version supported:
HTTP/1.1 - Request method supported:
GET - Response status supported:
200 OK400 Bad Request404 Not Found
- Request headers:
Host(required)Connection(optional,Connection: closehas special meaning influencing server logic)- Other headers are allowed, but won't have any effect on the server logic
- Response headers:
Date(required)Last-Modified(required for a200response)Content-Type(required for a200response)Content-Length(required for a200response)Connection: close(required in response for aConnection: closerequest, or for a400response)- Response headers should be written in sorted order for the ease of testing
- Response headers should be returned in 'canonical form', meaning that the first letter and any letter following a hyphen should be upper-case. All other letters in the header string should be lower-case.
When to send a 200 response?
- When a valid request is received, and the requested file can be found.
When to send a 404 response?
- When a valid request is received, and the requested file cannot be found or is not under the doc root.
When to send a 400 response?
- When an invalid request is received.
- When timeout occurs and a partial request is received.
When to close the connection?
- When timeout occurs and no partial request is received.
- When EOF occurs.
- After sending a
400response. - After handling a valid request with a
Connection: closeheader.
When to update the timeout?
- When trying to read a new request.
What is the timeout value?
- 5 seconds.
The source code for tools needed to interact with TritonHTTP can be found in cmd. The following commands can be used to launch these tools:
-
make fetch- A tool that allows you to construct custom responses and send them to your web server. Please refer to the README infetch's directory for more information. -
make gohttpd- Starts up Go's inbuilt web-server. -
make tritonhttpd- Starts up your implementation of TritonHTTP