SDTP syntax documentation
In the following grammars, letter
refers to any letter of the English alphabet, digit
to any integer from 0 through 9, path_segment_char
to any printable non-whitespace character other than forward- or back-slashes, char_no_newlines
to any non-newline character (i.e. not \r
or \n
), and arbitrary_data
to any bytes without restrictions.
Request syntax
Description
SDTP requests look very similar to HTTP requests. A request has three main sections: the request line, the headers and the body. These sections are separated from each other using a carriage return and new line (\r\n
). The headers and body are optional and are not required for most requests. In fact, they are included only for potential future expansion and are not currently implemented in SDTPServer or SDTPBrowser.
The request line is formed from a request method verb, followed by the path of the requested resource, followed by the version of SDTP to use.
Each header occupies a single line, separated by a carriage return and new line (\r\n
). They are of the format key=value
.
The body may contain any data whatsoever, but if it is present, its length in octets must be indicated via the length
header so that the server knows when to stop reading.
Grammar
request ::= request_line "\r\n" headers "\r\n" body request_line ::= method " " path " " version method ::= "GET" | "HEAD" path ::= "/" path_segment path | path_segment path_segment ::= path_segment_char path_segment | path_segment_char version ::= "SDTP/" int "." int int ::= digit int | digit headers ::= header headers | header header ::= key "=" value "\r\n" key ::= letter key | letter value ::= char_no_newlines value | char_no_newlines body ::= arbitrary_data
Example request
GET /assets/styles/main.sdss SDTP/0.1
Response syntax
Description
Just as with requests, SDTP responses look very similar to HTTP responses, and have three sections: the response line, the headers and the body, separated by a carriage return and a new line (\r\n
), with the headers and body optional.
The response line is formed from the SDTP version used in the response and the status of the request (a numerical code followed by one or more words describing the status).
Each header occupies a single line, separated by a carriage return and new line (\r\n
). They are of the format key=value
.
The body may contain any data whatsoever, but if it is present, its length in octets must be indicated via the length
header so that the browser knows when to stop reading.
Grammar
response ::= response_line "\r\n" headers "\r\n" body response_line ::= version " " status version ::= "SDTP/" int "." int status ::= int " " status_name status_name ::= letter status_name | " " status_name | letter | " " int ::= digit int | digit headers ::= header headers | header header ::= key "=" value "\r\n" key ::= letter key | letter value ::= char_no_newlines value | char_no_newlines body ::= arbitrary_data
Example response
SDTP/0.1 200 OK type=text/sdss length=117 server=SDTPServer 0.1 p { colour="#333" link { underline="none" } link<hover> { underline="single" } }