What is jsontp?
jsontpis a new standard, aimed to increase interoperability with existing standards across the web, rather than relying on the unique nature of HTTP.- it uses
TCPas the transport layer, andJSONas the data format, which is already widely used across the web.
Why jsontp?
jsontpis designed to be a more efficient and reliable way to transfer data across the web. It's standard is stricter than HTTP, and it's designed to be very similar if not the same across all platforms.- the standard, while written in formal English, is not written in a way that is difficult to understand. It's designed to be easy to understand and implement.
Core concepts
- there are two main concepts in
jsontp: therequestand theresponse. Therequestis the data that is sent to the server, and theresponseis the data that is sent back to the client. - the
requestandresponseare bothJSONobjects, and they are both sent overTCP. - they are both sent in a specific format, which is defined in the
jsontpstandard, and explained later in this book.
Types of Messages
- In this section, we will discuss the different types of Messages that can be made to the JSONTP server.
- There are two main types -
requestandresponse.
Request
- the request message is sent from the client to the server
- it is a
JSONobject, and follows a specific format, which is discussed line by line below
Request Format
{
"jsontp": "1.0",
"type": "request",
"resource": "/path/to/resource",
"method": "GET",
"headers": {
"key1": "value1",
},
"body": {
"key1": "value1",
"content": "raw text to be sent",
"encoding": "gzip"
}
}
Fields
- if a required field is not present, the server will respond with a
400 Bad Requeststatus code - if a field is provided that is not in the list below, the server will respond with a
400 Bad Requeststatus code - if a field is in an incorrect format, or is an incorrect type, the server will respond with a
400 Bad Requeststatus code
jsontp - string, required
- the version of the
jsontpstandard that the message follows - it is always in the form
major.minor(-rcx), wherexis the release candidate number - for example,
1.0,1.1,1.2-rc1, etc.
type - string, required
- the type of message, which in this case is
request.
resource - string, required
- the path to the resource that the client is requesting
- below are some examples of valid
resourcefields://index.htmlexample.com/index.htmlexample.com:8080/index.htmlexample.com:8080/route?query=stringexample.com:8080/route?query=string#fragmentpath/to/resourcejsontp://example.com:8080/path/to/resource
- different servers may handle this differently, so it is ideal to send requests in the first or second format, which is
/followed if necessary by the path to the resource
method - string, required
- the method to use when making the request
- below are the list of HTTP methods mentioned in the standard:
GETPOSTPUTDELETEOPTIONS
- bear in mind that the server may not support all of these methods, as it only is required to support
GETandPOST. If the server does not support the method, it will respond with a405 Method Not Allowedstatus code
headers - object, required
- the headers to send with the request
- the keys are the header names, and the values are the header values
- in the
requestthere are no required headers - below are some examples of valid
headersfields:{}{"key1": "value1"}{"key1": "value1", "key2": "value2"}
- all header keys are case-insensitive, so the server will treat
Content-Typeandcontent-typeas the same header - all header values are strings, so if a header value is not a string, the server will respond with a
400 Bad Requeststatus code - if a header is not in the list of headers that the standard mentions, the server will respond with a
400 Bad Requeststatus code - if a header is merely not supported by the server, the server will ignore the header, or respond with a
501 Not Implementedstatus code
body - object, required
- the body of the request
- the body can contain key-value pairs following the same rules as the
headersfield - however, the body must also contain two subfields,
contentandencoding
content - string, required
- the raw text to be sent as the body of the request.
- if the
contentfield is not present, the request is either aPOSTorPUTrequest, and the header"expect": "100-continue"is not present, the server will respond with a400 Bad Requeststatus code
encoding - string, required
- the encoding of the
contentfield - below are the list of allowed encodings:
gzipdeflatebr(Google's Brotli)identity(no encoding)
- if the encoding is not in the list above, the server will respond with a
412 Precondition Failedstatus code
The 100-Continue Header
- if the client is planning to send a large request, it can send the header
"expect": "100-continue"to the server - this tells the server to bear in mind that the client is planning to send a large request, and so it should not timeout as quickly
- if the server does not support the
100-Continueheader, it will respond with a501 Not Implementedstatus code - if the server supports the
100-Continueheader, it will respond with a100 Continuestatus code, and the client can then send the full request, in the same format as above. Notably different from HTTP, the full request is sent, not just the body - example of a request with the
100-Continueheader:
{
"jsontp": "1.0",
"type": "request",
"resource": "/path/to/resource",
"method": "GET",
"headers": {
"expect": "100-continue" // required (obviously!)
},
"body": {} // if not empty, it will be ignored
}
- once the server responds with a
100 Continuestatus code, the client can send the full request, in the same format as above
Example Request
{
"jsontp": "1.0",
"type": "request",
"resource": "/index.html",
"method": "POST",
"headers": {
"accept": "text/html",
"accept-encoding": "gzip, deflate",
},
"body": {
"content": "key1=value1&key2=value2&key3=value3",
"encoding": "identity"
}
}
Response
- the response message is sent by the server to the client
- it is sent in response to a
requestmessage - the response message is in the form of a JSON object
Response Format
{
"jsontp": "1.0",
"type": "response",
"status": {
"code": 200,
"formal-message": "OK",
"human-message": "The request was successful."
},
"resource": "/path/to/resource",
"headers": {
"date": "2024-01-01T00:00:00Z+00:00",
"language": "en-GB",
},
"body": {
"key1": "value1",
"content": "raw text to be sent",
"encoding": "gzip"
}
}
Fields
- if a required field is not present, the client might not be able to process the response, so it is vital that all fields are present
jsontp - string, required
- the version of the
jsontpstandard that the message follows - it is always in the form
major.minor(-rcx), wherexis the release candidate number - for example,
1.0,1.1,1.2-rc1, etc.
type - string, required
- the type of message, which in this case is
response.
status - object, required
- the status of the response
- it has three required subfields -
code,formal-message, andhuman-message
code - number, required
- the status code of the response, which must be a valid HTTP status code
- below are some examples of valid
codefields:200404500418503
formal-message - string, required
- the formal message of the status code
- this is the message corresponding to the status code
- below are some examples of valid
formal-messagefields:OKNot FoundInternal Server ErrorI'm a teapotService Unavailable
- this is case-insensitive
human-message - string, required
- the human-readable message of the status code
- this is a message that is intended for the user to read, and is not intended to be parsed by a machine
- therefore, it is not standardised, and can be anything, at the discretion of the server
- below are some examples of valid
human-messagefields:The request was successful.The resource was not found.The server encountered an error.I'm a teapot.The server is currently unavailable.
resource - string, required
- the path to the resource that the client is requesting
- though this was sent in the
requestmessage, it is also sent in theresponsemessage, so that the client can verify that the server is responding to the correct request, and the data has not been mangled in transit, or mistaken by the server
headers - object, required
- the headers to send with the response
- the keys are the header names, and the values are the header values
- in the
responsefield there are two required headers -dateandlanguage
date - string, required
- the date and time that the response was sent
- it is in the form
YYYY-MM-DDTHH:MM:SSZ+0000, whereZis the timezone offset - it should be in the
UTCtimezone, but if it is not, the server should include the timezone offset, with no colon and no space between theZand the offset - for example,
2024-01-01T00:00:00Z+0000,2024-01-01T00:00:00Z-0500,2024-01-01T00:00:00Z+0530, etc.
language - string, required
- the
languageheader is used to tell the client the language of the response. - the language must be in the format
ISO 639-1language code, followed by a hyphen, and then a validISO 3166 Alpha 2country code. - for example,
en-GB,en-US,fr-FR,de-DE, etc.
Headers
- jsontp headers are the headers that are sent with the
requestandresponsemessages - they are more strictly defined than HTTP headers, and are designed to be more reliable
- however, they are still very similar to HTTP headers, and are designed to be easy to understand and implement
- unlike HTTP headers, jsontp headers are case-insensitive
Shared headers
content-type
- The
content-typeheader is used to specify the type of the content in the message body. - It is a valid MIME type.
- If it is sent from the client, and the server does not support the specified type, it should respond with a
415 Unsupported Media Typestatus code.
Request headers
- all request headers are optional
accept-encoding - array or string
- the
accept-encodingheader is used to specify the encoding that the client can accept - it is a list of encodings, in order of preference
- if it is a string, it is a single encoding
- if it is an array, it is a list of encodings
- if the server does not support the specified encoding, it should respond with a
412 Precondition Failedstatus code - valid encodings are
gzip,deflate,br,identity(no encoding)
accept-language - array or string
- the
accept-languageheader is used to specify the language that the client can accept - much like the
accept-encodingheader, it is a list of languages, in order of preference - if the server does not support the specified language, it should respond with a
406 Not Acceptablestatus code - valid languages are ISO 639-1 language codes, followed by a hyphen, and then a valid ISO 3166 Alpha 2 country code
- e.g.
en-US,fr-CA
authorization - string
- the
authorizationheader is used to specify the credentials that the client is using to authenticate itself - the value is a string, the exact format of which is determined by the server's configuration
cookies - object
- the
cookiesheader is used to specify the cookies that the client has - it is an object, where the keys are the names of the cookies, and the values are the cookies themselves
- e.g.
{"cookie1": "value1", "cookie2": "value2"} - if they are in an invalid format, the server will respond with a
400 Bad Requeststatus code
if-modified-since - string
- the
if-modified-sinceheader is used to tell the server to only send the message if it has been modified since the specified date - the value is a string, in the format
%Y-%m-%dT%H:%M:%SZ%z - if it has not been modified, the server will respond with a
304 Not Modifiedstatus code
if-unmodified-since - string
- the
if-unmodified-sinceheader is used to tell the server to only send the message if it has not been modified since the specified date - the value is a string, in the format
%Y-%m-%dT%H:%M:%SZ%z - if it has been modified, the server will respond with a
412 Precondition Failedstatus code
expect - string (only 100-continue is supported)
- the
expectheader is used to tell the server to only send the message if the specified condition is met - the only supported value is
100-continue - if the server does not support the specified condition, it should respond with a
501 Not Implementedstatus code
ignore-invalid-headers - boolean
- the
ignore-invalid-headersheader is used to tell the server to ignore any headers that it does not understand - if set to
true, the server will ignore any headers that it does not understand - if set to
false, the server will respond with a400 Bad Requeststatus code if it encounters any headers that it does not understand - should be
falseby default
Response headers
date - string, required
- the
dateheader is used to specify the date and time at which the message was sent. - it is always in the format
%Y-%m-%dT%H:%M:%SZ%z. - it should be in UTC time.
- e.g.
2019-01-01T00:00:00Z+0000
language - string, required
- the
languageheader is used to specify the language of the message body. - it is in the format ISO 639-1 language code, followed by a hyphen, and then a valid ISO 3166 Alpha 2 country code.
- e.g.
en-US,fr-CA
set-cookies - object, required
- the
set-cookiesheader is used to specify the cookies that should be set on the client. - it is an object, where the keys are the names of the cookies, and the values are the cookies themselves.
- e.g.
{"cookie1": "value1", "cookie2": "value2"} - if they are in an invalid format, the server will respond with a
400 Bad Requeststatus code.
Status Codes
- jsontp uses HTTP status codes to indicate the success or failure of a request.
- any valid HTTP status code is a valid jsontp status code - the only difference is that the message body is in JSON format.
- while any status code can be used as the server sees fit, there are a few mentioned in the specification that are used in a specific way.
505 HTTP Version Not Supported
- if the server does not support the version of jsontp that the client is using, it should respond with a
505 HTTP Version Not Supportedstatus code.
400 Bad Request
- if the server does not understand the request, it should respond with a
400 Bad Requeststatus code. - this is mentioned numerous times in the specification, and is used in a variety of contexts.
405 Method Not Allowed
- if the server does not support the method that the client is using, it should respond with a
405 Method Not Allowedstatus code.
406 Not Acceptable
- if the server does not support the language that the client is using, it should respond with a
406 Not Acceptablestatus code.
412 Precondition Failed
- used for conditional requests that cannot be met, or also in the case of the
if-unmodified-sinceheader when the resource has been modified
415 Unsupported Media Type
- used for unsupported MIME types
404 Not Found
- used for resources that do not exist
304 Not Modified
- used for conditional requests that have not been modified
501 Not Implemented
- used for unsupported conditions, such as the
expectheader
jsontp versioning
- the jsontp version is in the format major.minor(-rcx)
- the major version is incremented when there are breaking changes the minor version is incremented when there are non-breaking changes (though this may never happen)
- the rcx is the release candidate number, and will only be present in a release candidate version, for example, 1.0-rc1. It will not be present in a stable release. If it is present, it should be incremented with each release candidate, and omitted in the stable release.
- the jsontp version is always in the jsontp key-value pair, which is mandatory in all jsontp messages.
- if the jsontp version is not supported, the server should respond with a 505 HTTP Version Not Supported status code.
- if the jsontp version is not provided, the server should respond with a 400 Bad Request status code.
- examples:
1.0,1.2-rc3,2.3
jsontp - version 1.0-rc2
-
jsonis the ubiquitous data interchange format for the web -
HTTPis the ubiquitous protocol for the web -
but
HTTPis not easy to parse -
jsontpis an protocol that usesjsonas its data interchange format -
the
HTTPspecification is often changed, whilst thejsonspecification is stable -
the
jsontpprotocol is designed to be easy to parse and easy to generate -
the
jsontpprotocol is sent overTCP
the jsontp protocol
- there are two types of
jsontpmessages:requestandresponse - a
requestmessage is sent from client to server, and aresponsemessage is sent from server to client
graph TD
A[Client] -->|request| B[Server]
B -->|response| A
the jsontp request message
- the
jsontprequest message is sent from the client to the server - it must always include:
- the
jsontpkey-value pair - the
typekey-value pair - the
resourcekey-value pair - the
methodkey-value pair - the
headersobject (no mandatory headers in the request, but must always be present even if empty, in which case it should be{}) - the
bodyobject - the
bodyobject must always include:- the
contentkey-value pair - the
encodingkey-value pair
- the
- the
{
"jsontp": "1.0", // required and in the format `major.minor`
"type": "request",
"resource": "/path/to/resource",
"method": "GET",
"headers": { // no required headers in the request
"key1": "value1",
},
"body": {
"key1": "value1", // optional
"content": "raw text to be sent", // must always be present, even if empty
"encoding": "gzip" // required, but can be `identity` if no encoding is used
}
}
the jsontp response message
- the
jsontpresponse message is sent from the server to the client - it must always include:
- the
jsontpkey-value pair - the
statusobject - the
resourcekey-value pair - the
headersobject - the
bodyobject - the
statusobject must always include:- the
codekey-value pair - the
formal-messagekey-value pair - the
human-messagekey-value pair
- the
- the
headersobject must always include:- the
datekey-value pair - the
languagekey-value pair
- the
- the
bodyobject must always include:- the
contentkey-value pair - the
encodingkey-value pair
- the
- the
{
"jsontp": "1.0", // required and in the format `major.minor(-rcx)` (explained more in the `jsontp` versioning section)
"type": "response",
"status": {
"code": 200, // a valid `HTTP` status code (not 1xx)
"formal-message": "OK", // a valid `HTTP` status message
"human-message": "The request was successful." // a human-readable message, the contents of which is up to the discretion of the server, but should be helpful to the client. It is required, but can be a copy of the `formal-message` if the server wishes.
},
"resource": "/path/to/resource",
"headers": {
"date": "2024-01-01T00:00:00Z+00:00", // required and always in this format. Should always be in UTC, but a compliant client should accept any timezone
"language": "en-US", // required and always in this format (explained more in the `response` headers section)
},
"body": {
"key1": "value1", // optional
"content": "raw text to be sent", // must always be present, even if empty
"encoding": "gzip" // required, but can be `identity` if no encoding is used
}
}
the jsontp 100 Continue request message
{
"jsontp": "1.0", // required and in the format `major.minor`
"type": "request",
"resource": "/path/to/resource",
"method": "GET",
"headers": {
"expect": "100-continue" // required
},
"body": {} // if not empty, it will be ignored
}
the jsontp 100 Continue response message
{
"jsontp": "1.0", // required and in the format `major.minor(-rcx)` (explained more in the `jsontp` versioning section)
"type": "response",
"status": {
"code": 100, // either 100, or a 4xx or 5xx error code
"formal-message": "CONTINUE", // corresponding status code
"human-message": "Ackknowledgement on the 100 Continue message"
},
"resource": "/path/to/resource",
"headers": {
"date": "2024-01-01T00:00:00Z+00:00", // required and always in this format. Should always be in UTC, but a compliant client should accept any timezone
"language": "en-US", // required and always in this format (explained more in the `response` headers section
},
"body": {} // should be empty, ignored if not
}
content requirements of certain key-value pairs
jsontp
- the
jsontpkey-value pair is always in the formatmajor.minor(-rcx) - this is explained more in the
jsontpversioning section - if the
jsontpversion is not supported, the server should respond with a505 HTTP Version Not Supportedstatus code - if the
jsontpversion is not provided, the server should respond with a400 Bad Requeststatus code
type
- must be either
requestorresponse - if the
typeis not supported, the server should respond with a400 Bad Requeststatus code
method
- the
methodkey-value pair is theHTTPmethod that the client is using to request the resource - the
methodkey-value pair can be any of the following:GET- standard request for the resource, which follows the
requestspecification exactly
- standard request for the resource, which follows the
POST- same as get, but the server must attempt to parse the body as a
&-separated list of key-value pairs. If not, that is no problem, and the server can proceed as usual
- same as get, but the server must attempt to parse the body as a
PUT- the
resourceis to be created or replaced with thecontentof thebody - if successful, the server should respond with a
201 Createdstatus code
- the
DELETE- the
resourceis to be deleted - the
bodyshould be ignored. - if successful, the server should respond with a
204 No Contentstatus code
- the
OPTIONS- the server should respond with a
200 OKstatus code, and thebodyshould contain akeyentitledallowed-methods, and thevalueshould be an array of the allowed methods. - It should ignore the
bodyof therequestmessage.
- the server should respond with a
- if the
methodis not supported, the server should respond with a405 Method Not Allowedstatus cod - a compliant server must implement at least the
GETandOPTIONSmethods
status
- the
statuskey-value pair is always anobject
code
- the
codekey-value pair is always a validHTTPstatus code (not 1xx).
formal-message
- the
formal-messagekey-value pair is always a validHTTPstatus message corresponding to thecode, for example,OKfor200,Not Foundfor404, etc. It is case-insensitive.
human-message
- the
human-messagekey-value pair is always a human-readable message, the contents of which is up to the discretion of the server, but should be helpful to the client. It is required, but can be a copy of theformal-messageif the server wishes.
resource
- the
resourcekey-value pair is the path to the resource that the client is requesting - the
resourcekey-value pair can be in any of the following formats:/path/to/resource/path/to/resource/path/to/resourcepath/to/resource/site.com/path/to/resourcejsontp://site.com/path/to/resource
- if the
resourceformat is not supported, the server should respond with a400 Bad Requeststatus code - if the
resourceis not found, the server should respond with a404 Not Foundstatus code
valid headers
- headers are always in the format
{ "key": "value" } - the
keyis always astring, and thevaluecan be any type barundefinedandnull - the
keyis always case-insensitive - the
valueis always case-sensitive - if an invalid header is provided, the server should respond with a
400 Bad Requeststatus code, however, this shouldn"t happen if the headerignore-invalid-headersis set totrue
headers in request and response messages
content-type - string
- the
MIMEtype of thebodyorcontentof the message - if the
MIMEtype is not supported, the server should respond with a415 Unsupported Media Typestatus code
accept - array or string
- the
MIMEtype of thebodyorcontentthat the client is willing to accept. - If the server cannot provide the
MIMEtype, it should respond with a415 Unsupported Media Typestatus code. - If there are multiple allowed
MIMEtypes, they should ideally be ajsonarray, but astringis also acceptable. - For example:
["text/html", "application/json", "application/xml"]or"text/html, application/json, application/xml"
request headers
accept-encoding - array or string
- the encoding that the client is willing to accept.
- If the server cannot provide the encoding, it should respond with a
412 Precondition Failedstatus code. - If there are multiple allowed encodings, they should ideally be a
jsonarray, but astringis also acceptable. - For example:
["gzip", "deflate", "br", "identity"]or"gzip, deflate, br, identity" - Allowed encodings are:
gzip,deflate,br,identity
accept-language - array or string
- the language that the client is willing to accept.
- If the server cannot provide the language, it should respond with a
406 Not Acceptablestatus code. - If there are multiple allowed languages, they should ideally be a
jsonarray, but astringis also acceptable. - For example:
["en-US", "en-GB", "en-CA"]or"en-US, en-GB, en-CA" - Each must first be a valid
ISO 639-1language code, followed by a hyphen, and then a validISO 3166 Alpha 2country code.
authorization - string
- the
authorizationheader is used to authenticate the client with the server. - the
authorizationheader should be in the format<token>, where<token>is the token that the server has provided to the client. - if the server cannot authenticate the client, it should respond with a
401 Unauthorizedstatus code.
cookies - object or string
- the
cookiesheader is used to send cookies to the server. - the
cookiesheader should be a smalljsonobject, with the keys being the cookie names, and the values being the cookie values. - if the server cannot accept the cookies, it should respond with a
400 Bad Requeststatus code. - example:
"cookies": {"cookie1": "value1", "cookie2": "value2"} - however, a compliant server will also accept cookies in the format
"cookie1=value1; cookie2=value2", as this is the format that theHTTPspecification uses, andjsontpis designed to be maximally compatible with existing standards.
if-modified-since - string in the strftime format (that found given in man 3 strftime) %Y-%m-%dT%H:%M:%SZ%z
- the
if-modified-sinceheader is used to tell the server that the client only wants the resource if it has been modified since the date provided. - the date should be in the format
%Y-%m-%dT%H:%M:%SZ%z, and should always be inUTC, but a compliant server should accept any timezone (although it should convert it toUTCbefore comparing it to the last modified date of the resource, which should always be inUTC). - if the server cannot provide the resource, it should respond with a
412 Precondition Failedstatus code. - if the server could provide the resource, but it has not been modified since the date provided, it should respond with a
304 Not Modifiedstatus code. - example value:
2024-01-01T00:00:00Z+0000(no colon is permitted in the timezone offset)
if-unmodified-since - string in the strftime format (that found given in man 3 strftime) %Y-%m-%dT%H:%M:%SZ%z
- the
if-unmodified-sinceheader is used to tell the server that the client only wants the resource if it has not been modified since the date provided. - the date should be in the format
%Y-%m-%dT%H:%M:%SZ%z, and should always be inUTC, but a compliant server should accept any timezone (although it should convert it toUTCbefore comparing it to the last modified date of the resource, which should always be inUTC). - if the server cannot provide the resource, it should respond with a
412 Precondition Failedstatus code. - if the server could provide the resource, but it has been modified since the date provided, it should respond with a
412 Precondition Failedstatus code. Unfortunately, theHTTPspecification does not provide a status code for this (3xx Modified), sojsontphas to use412 Precondition Failedinstead, as does theHTTPspecification. - example value:
2024-01-01T00:00:00Z+0000(no colon is permitted in the timezone offset)
expect - string (namely 100-continue)
- used to tell the server that the body will be sent in the next request, and not to time out quickly
- first, the client sends a message in the format specified above, then the server responds, again set out above. If the server does not support
100-continue, it must respond with a501 Not Implementedstatus code, at which point the connection will terminate. - if the server responds with
100 Continue, the client then sends its request in the usual fashion, containing all required fields, including headers. The client can modify the headers for this second request if they need to for some reason. -
ignore-invalid-headers-boolean - if the
ignore-invalid-headersheader is set totrue, the server should ignore any invalid headers, and not respond with a400 Bad Requeststatus code. - if the
ignore-invalid-headersheader is set tofalse, the server should respond with a400 Bad Requeststatus code if any invalid headers are provided.
response headers
date - string in the strftime format (that found given in man 3 strftime) %Y-%m-%dT%H:%M:%SZ%z
- the
dateheader is used to tell the client the date and time that the response was generated. - the date should be in the format
%Y-%m-%dT%H:%M:%SZ%z, and should always be inUTC, but a compliant client should accept any timezone. - if the server cannot provide the date, it should respond with a
500 Internal Server Errorstatus code. - this header is always present in a
responsemessage. - example value:
2024-01-01T00:00:00Z+0000(no colon is permitted in the timezone offset)
language - string
- the
languageheader is used to tell the client the language of the response. - the language must be in the format
ISO 639-1language code, followed by a hyphen, and then a validISO 3166 Alpha 2country code. - if the language does not match this format, the server should respond with a
400 Bad Requeststatus code. - if the server cannot provide the language, it should respond with a
500 Internal Server Errorstatus code.
set-cookies - object
- the
set-cookiesheader is used to tell the client to set cookies. - the
set-cookiesheader should be a smalljsonobject, with the keys being the cookie names, and the values being the cookie values. - example:
"set-cookies": {"cookie1": "value1", "cookie2": "value2"} - the server must respond with an
object, not astring, as theHTTPspecification does not allow for multipleset-cookieheaders to be sent in a single response, and sojsontpmust use ajsonobject to represent multiple cookies.
Other important requirements
jsontp versioning
- the
jsontpversion is in the formatmajor.minor(-rcx) - the
majorversion is incremented when there are breaking changes - the
minorversion is incremented when there are non-breaking changes (though this may never happen) - the
rcxis the release candidate number, and will only be present in a release candidate version, for example,1.0-rc1. It will not be present in a stable release. If it is present, it should be incremented with each release candidate, and omitted in the stable release. - the
jsontpversion is always in thejsontpkey-value pair, which is mandatory in alljsontpmessages. - if the
jsontpversion is not supported, the server should respond with a505 HTTP Version Not Supportedstatus code. - if the
jsontpversion is not provided, the server should respond with a400 Bad Requeststatus code.
errors on the server's side
- if the server encounters an error, it should respond with a
5xx Server Errorstatus code. - the
messagekey-value pair in thestatusobject should be a human-readable error message.
where to submit feature requests
- feature requests can be submitted to the
jsontp/paperGitHub repository, or can be emailed directly to thejsontpmaintainers, the email address of which is provided in thejsontpGitHub organization.
comments
- comments should not be included in any message, but a compliant implementation should allow them.
The "expect": "100-continue" header
- This is explained in the section on the valid client headers, but below is a nice mermaid diagram
sequenceDiagram
Client ->> Server: body-less request
Server ->> Client: 100 continue response (or 501, if so the connection ends)
Client ->> Server: full request
Server ->> Client: full response