11# Solid HTTPS REST API Spec
22
3- ** Note:** This spec is a component of the parent
3+ *** Note:** This spec is a component of the parent
44[ Solid specification] ( README.md ) ; the parent spec and all its components are
5- versioned as a whole.
5+ versioned as a whole.*
66
77## Reading Resources
88
9- Resources can be commonly accessed (i.e. read) using HTTP GET requests. Solid
9+ Resources can be commonly accessed (i.e., read) using HTTP ` GET ` requests. Solid
1010servers are encouraged to perform content negotiation for RDF resources,
1111depending on the value of the ` Accept ` header.
1212
13- ** IMPORTANT:** a default ` Content-Type: text/turtle ` will be used for requests
13+ *** IMPORTANT:** a default ` Content-Type: text/turtle ` will be used for requests
1414for RDF resources or views (containers) that do not have an ` Accept `
15- header.
15+ header.*
1616
1717### Streams
1818
19- Being LDP (BasicContainer) compliant, Solid servers MUST return a full listing
19+ Being LDP (` BasicContainer ` ) compliant, Solid servers MUST return a full listing
2020of container contents when receiving requests for containers. For every resource
2121in a container, a Solid server may include additional metadata, such as the time
2222the resource was modified, the size of the resource, and more importantly any
@@ -31,14 +31,14 @@ container maps to a file or a directory on the server, using the [POSIX
3131vocabulary] ( http://www.w3.org/ns/posix/stat# ) . Here is an example that reflects
3232how our current server implementations handle such a request:
3333
34- REQUEST:
34+ ** REQUEST**
3535
3636``` http
3737GET /
3838Host: example.org
3939```
4040
41- RESPONSE:
41+ ** RESPONSE**
4242
4343``` http
4444HTTP/1.1 200 OK
@@ -58,44 +58,44 @@ HTTP/1.1 200 OK
5858 <http://www.w3.org/ns/posix/stat#size> "780" .
5959```
6060
61- #### Globbing (inlining on GET)
61+ #### Globbing (inlining on ` GET ` )
6262
63- We have found that in some cases, using the existing LDP features was not
64- enough. For instance, to optimize certain applications we needed to aggregate
65- all RDF resources from a container and retrieve them with a single GET
63+ In some cases, we have found that using the existing LDP features was not
64+ enough. For instance, to optimize certain applications, we needed to aggregate
65+ all RDF resources from a container and retrieve them with a single ` GET `
6666operation. We implemented this feature on the servers and decided to call it
6767"globbing". Similar to [ UNIX shell
68- glob] ( https://en.wikipedia.org/wiki/Glob_(programming) ) , doing a GET on any URI
68+ glob] ( https://en.wikipedia.org/wiki/Glob_(programming) ) , doing a ` GET ` on any URI
6969which ends with a ` * ` will return an aggregate view of all the resources that
7070match the indicated pattern.
7171
7272For example, let's assume that ` /data/res1 ` and ` /data/res2 ` are two resources
7373containing one triple each, which defines their type as follows:
7474
75- For * res1* :
75+ ** For * res1***
7676
7777``` ttl
7878<> a <https://example.org/ns/type#One> .
7979```
8080
81- For * res2* :
81+ ** For * res2***
8282
8383``` ttl
8484<> a <https://example.org/ns/type#Two> .
8585```
8686
8787If one would like to fetch all resources of a container beginning with ` res `
88- (e.g. ` /data/res1 ` , ` /data/res2 ` ) in one request, they could do a GET on
88+ (e.g., ` /data/res1 ` , ` /data/res2 ` ) in one request, they could do a ` GET ` on
8989` /data/res* ` as follows.
9090
91- REQUEST:
91+ ** REQUEST**
9292
9393``` http
9494GET /data/res* HTTP/1.1
9595Host: example.org
9696```
9797
98- RESPONSE:
98+ ** RESPONSE**
9999
100100``` http
101101HTTP/1.1 200 OK
@@ -111,14 +111,14 @@ HTTP/1.1 200 OK
111111Alternatively, one could ask the server to inline * all* resources of a
112112container, which includes the triples corresponding to the container itself:
113113
114- REQUEST:
114+ ** REQUEST**
115115
116116``` http
117117GET /data/* HTTP/1.1
118118Host: example.org
119119```
120120
121- RESPONSE:
121+ ** RESPONSE**
122122
123123``` http
124124HTTP/1.1 200 OK
@@ -143,24 +143,24 @@ apply to children containers.
143143Another possible way of reading and writing data is to use SPARQL. Currently,
144144our Solid servers support a subset of [ SPARQL
1451451.1] ( https://www.w3.org/TR/sparql11-overview/ ) , where each resource is its own
146- SPARQL endpoint, accepting basic SELECT, INSERT and DELETE statements.
146+ SPARQL endpoint, accepting basic ` SELECT ` , ` INSERT ` , and ` DELETE ` statements.
147147
148148To read (query) a resource, the client can send a SPARQL ` SELECT ` through a
149- form-encoded HTTP GET request. The server will use the given resource as the
149+ form-encoded HTTP ` GET ` request. The server will use the given resource as the
150150default graph that is being queried. The resource can be an RDF document or even
151- a container. The response will be serialized using ` application/json ` mime type.
151+ a container. The response will be serialized using ` application/json ` MIME type.
152152
153- For instance, the client can send the following form-encoded query `SELECT *
153+ For instance, the client can form-encode and send the query `SELECT *
154154WHERE { ?s ?p ?o . }`:
155155
156- REQUEST:
156+ ** REQUEST**
157157
158158``` http
159159GET /data/?query=SELECT%20*%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20.%20%7D HTTP/1.1
160160Host: example.org
161161```
162162
163- RESPONSE:
163+ ** RESPONSE**
164164
165165``` http
166166HTTP/1.1 200 OK
@@ -207,10 +207,10 @@ to the following value:
207207` Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type" `
208208
209209For example, to create a basic container called ` data ` under
210- ` https://example.org/ ` , the client will need to send the following POST request,
211- with the Content-Type header set to ` text/turtle ` :
210+ ` https://example.org/ ` , the client will need to send the following ` POST ` request,
211+ with the ` Content-Type ` header set to ` text/turtle ` :
212212
213- REQUEST:
213+ ** REQUEST**
214214
215215``` http
216216POST / HTTP/1.1
@@ -223,7 +223,7 @@ Slug: data
223223<> <http://purl.org/dc/terms/title> "Basic container" .
224224```
225225
226- RESPONSE:
226+ ** RESPONSE**
227227
228228``` http
229229HTTP/1.1 201 Created
@@ -236,10 +236,10 @@ value:
236236` Link: <http://www.w3.org/ns/ldp#Resource>; rel="type" `
237237
238238For example, to create a resource called ` test ` under
239- ` https://example.org/data/ ` , the client will need to send the following POST
240- request, with the Content-Type header set to ` text/turtle ` :
239+ ` https://example.org/data/ ` , the client will need to send the following ` POST `
240+ request, with the ` Content-Type ` header set to ` text/turtle ` :
241241
242- REQUEST:
242+ ** REQUEST**
243243
244244``` http
245245POST / HTTP/1.1
@@ -252,22 +252,22 @@ Slug: test
252252<> <http://purl.org/dc/terms/title> "This is a test file" .
253253```
254254
255- RESPONSE:
255+ ** RESPONSE**
256256
257257``` http
258258HTTP/1.1 201 Created
259259```
260260
261261More examples can be found in the LDP [ Primer document] ( http://www.w3.org/TR/ldp-primer/ ) .
262262
263- #### HTTP PUT to create
263+ #### HTTP ` PUT ` to create
264264
265265An alternative (though not standard) way of creating new resources is to use
266- HTTP PUT. Although HTTP PUT is commonly used to overwrite resources, this way is
267- usually preferred when creating new non-RDF resources (i.e. using a mime type
268- different than ` text/turtle ` ).
266+ HTTP ` PUT ` . Although HTTP ` PUT ` is commonly used to overwrite resources, this way is
267+ usually preferred when creating new non-RDF resources (i.e., using a MIME type
268+ other than ` text/turtle ` ).
269269
270- REQUEST:
270+ ** REQUEST**
271271
272272``` http
273273PUT /picture.jpg HTTP/1.1
@@ -276,23 +276,23 @@ Content-Type: image/jpeg
276276...
277277```
278278
279- RESPONSE :
279+ ** RESPONSE**
280280
281281``` http
282282HTTP/1.1 201 Created
283283```
284284
285285Another useful Solid feature that is not yet part of the LDP spec deals with
286- using HTTP PUT to * recursively* create new resources. This feature is really
286+ using HTTP ` PUT ` to * recursively* create new resources. This feature is really
287287useful when the client wants to make sure it has absolute control over the URI
288- namespace -- e.g. migrating from one personal data store to another. Although
288+ namespace -- e.g., migrating from one personal data store to another. Although
289289this feature is defined in HTTP1.1
290290[ RFC2616] ( https://tools.ietf.org/html/rfc2616 ) , we decided to improve it
291291slightly by having servers create the full path to the resource (including
292292intermediate containers), if it didn't exist before. (If you're familiar with
293293the Unix command line, think of it as ` mkdir -p ` .) For instance, a calendar app
294- uses a URI pattern (structure) based on dates when storing new events (i.e.
295- yyyy/mm/dd). Instead of performing several POST requests to create a month and a
294+ uses a URI pattern (structure) based on dates when storing new events (i.e.,
295+ ` yyyy/mm/dd ` ). Instead of performing several POST requests to create a month and a
296296day container when switching to a new month, it could send the following request
297297to create a new event resource called ` event1 ` :
298298
@@ -314,25 +314,25 @@ missing intermediate resources -- containers for the month `05` and the day `01`
314314under the parent container ` /2015/ ` .
315315
316316To avoid accidental overwrites, Solid servers must support ` ETag ` checking
317- through the use of [ If-Match or
318- If-None-Match] ( https://tools.ietf.org/html/rfc2616#section-14.24 ) HTTP headers.
317+ through the use of [ ` If-Match ` or
318+ ` If-None-Match ` ] ( https://tools.ietf.org/html/rfc2616#section-14.24 ) HTTP headers.
319319
320- ** IMPORTANT:** Using PUT to create standalone containers is not supported,
321- because the behavior of PUT (overwrite) is not well defined for containers. You
322- MUST use POST (as defined by LDP) to create containers alone.
320+ *** IMPORTANT:** Using ` PUT ` to create standalone containers is not supported,
321+ because the behavior of ` PUT ` (overwrite) is not well defined for containers. You
322+ MUST use ` POST ` (as defined by LDP) to create containers alone.*
323323
324324#### Alternative: Using SPARQL
325325
326- To write data, clients can send an HTTP PATCH request with a SPARQL payload to
326+ To write data, clients can send an HTTP ` PATCH ` request with a SPARQL payload to
327327the resource in question. If the resource doesn't exist, it should be created
328- through an LDP POST or through a PUT.
328+ through an LDP ` POST ` or through a ` PUT ` .
329329
330330For instance, to update the ` title ` of the container from the previous example,
331- the client would have to send a DELETE statement, followed by an INSERT
331+ the client would have to send a ` DELETE ` statement, followed by an ` INSERT `
332332statement. Multiple statements (delimited by a ` ; ` ) can be sent in the same
333- PATCH request.
333+ ` PATCH ` request.
334334
335- REQUEST:
335+ ** REQUEST**
336336
337337``` http
338338PATCH /data/ HTTP/1.1
@@ -344,27 +344,30 @@ DELETE DATA { <> <http://purl.org/dc/terms/title> "Basic container" };
344344INSERT DATA { <> <http://purl.org/dc/terms/title> "My data container" }
345345```
346346
347- RESPONSE:
347+ ** RESPONSE**
348348
349349``` http
350350HTTP/1.1 200 OK
351351```
352352
353- ** IMPORTANT:** There is currently no support for blank nodes and RDF lists in
354- our SPARQL patches.
353+ *** IMPORTANT:** There is currently no support for blank nodes nor RDF lists in
354+ our SPARQL patches.*
355355
356- ### Discovering server capabilities - the OPTIONS method
356+ ### Discovering server capabilities - the ` OPTIONS ` method
357357
358- Returns a list of headers describing the server's capabilities.
358+ Returns a list of headers describing the server's capabilities (with an
359+ asterisk \[ ` * ` \] as the ` request-target ` ), or the subset of those capabilities
360+ which are made available on a specific resource (if specified as the
361+ ` request-target ` ).
359362
360- REQUEST:
363+ ** REQUEST**
361364
362365``` http
363- OPTIONS /data/ HTTP/1.1
366+ OPTIONS * HTTP/1.1
364367Host: example.org
365368```
366369
367- RESPONSE:
370+ ** RESPONSE**
368371
369372``` http
370373HTTP/1.1 200 OK
@@ -375,4 +378,27 @@ Access-Control-Allow-Methods: OPTIONS, HEAD, GET, PATCH, POST, PUT, DELETE
375378Access-Control-Allow-Origin: *
376379Access-Control-Expose-Headers: User, Triples, Location, Link, Vary, Last-Modified, Content-Length
377380Allow: OPTIONS, HEAD, GET, PATCH, POST, PUT, DELETE
381+ MS-Author-Via: DAV, SPARQL
382+ ```
383+
384+ ** REQUEST**
385+
386+ ``` http
387+ OPTIONS /data/ HTTP/1.1
388+ Host: example.org
389+ ```
390+
391+ ** RESPONSE**
392+
393+ ``` http
394+ HTTP/1.1 200 OK
395+ Accept-Patch: application/sparql-update
396+ Accept-Post: text/turtle
397+ Access-Control-Allow-Credentials: true
398+ Access-Control-Allow-Methods: OPTIONS, HEAD, GET, PATCH, POST
399+ Access-Control-Allow-Origin: *
400+ Access-Control-Expose-Headers: User, Triples, Location, Link, Vary, Last-Modified, Content-Length
401+ Allow: OPTIONS, HEAD, GET, PATCH, POST
402+ MS-Author-Via: SPARQL
403+
378404```
0 commit comments