1
1
# Solid HTTPS REST API Spec
2
2
3
- ** Note:** This spec is a component of the parent
3
+ *** Note:** This spec is a component of the parent
4
4
[ Solid specification] ( README.md ) ; the parent spec and all its components are
5
- versioned as a whole.
5
+ versioned as a whole.*
6
6
7
7
## Reading Resources
8
8
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
10
10
servers are encouraged to perform content negotiation for RDF resources,
11
11
depending on the value of the ` Accept ` header.
12
12
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
14
14
for RDF resources or views (containers) that do not have an ` Accept `
15
- header.
15
+ header.*
16
16
17
17
### Streams
18
18
19
- Being LDP (BasicContainer) compliant, Solid servers MUST return a full listing
19
+ Being LDP (` BasicContainer ` ) compliant, Solid servers MUST return a full listing
20
20
of container contents when receiving requests for containers. For every resource
21
21
in a container, a Solid server may include additional metadata, such as the time
22
22
the 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
31
31
vocabulary] ( http://www.w3.org/ns/posix/stat# ) . Here is an example that reflects
32
32
how our current server implementations handle such a request:
33
33
34
- REQUEST:
34
+ ** REQUEST**
35
35
36
36
``` http
37
37
GET /
38
38
Host: example.org
39
39
```
40
40
41
- RESPONSE:
41
+ ** RESPONSE**
42
42
43
43
``` http
44
44
HTTP/1.1 200 OK
@@ -58,44 +58,44 @@ HTTP/1.1 200 OK
58
58
<http://www.w3.org/ns/posix/stat#size> "780" .
59
59
```
60
60
61
- #### Globbing (inlining on GET)
61
+ #### Globbing (inlining on ` GET ` )
62
62
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 `
66
66
operation. We implemented this feature on the servers and decided to call it
67
67
"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
69
69
which ends with a ` * ` will return an aggregate view of all the resources that
70
70
match the indicated pattern.
71
71
72
72
For example, let's assume that ` /data/res1 ` and ` /data/res2 ` are two resources
73
73
containing one triple each, which defines their type as follows:
74
74
75
- For * res1* :
75
+ ** For * res1***
76
76
77
77
``` ttl
78
78
<> a <https://example.org/ns/type#One> .
79
79
```
80
80
81
- For * res2* :
81
+ ** For * res2***
82
82
83
83
``` ttl
84
84
<> a <https://example.org/ns/type#Two> .
85
85
```
86
86
87
87
If 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
89
89
` /data/res* ` as follows.
90
90
91
- REQUEST:
91
+ ** REQUEST**
92
92
93
93
``` http
94
94
GET /data/res* HTTP/1.1
95
95
Host: example.org
96
96
```
97
97
98
- RESPONSE:
98
+ ** RESPONSE**
99
99
100
100
``` http
101
101
HTTP/1.1 200 OK
@@ -111,14 +111,14 @@ HTTP/1.1 200 OK
111
111
Alternatively, one could ask the server to inline * all* resources of a
112
112
container, which includes the triples corresponding to the container itself:
113
113
114
- REQUEST:
114
+ ** REQUEST**
115
115
116
116
``` http
117
117
GET /data/* HTTP/1.1
118
118
Host: example.org
119
119
```
120
120
121
- RESPONSE:
121
+ ** RESPONSE**
122
122
123
123
``` http
124
124
HTTP/1.1 200 OK
@@ -143,24 +143,24 @@ apply to children containers.
143
143
Another possible way of reading and writing data is to use SPARQL. Currently,
144
144
our Solid servers support a subset of [ SPARQL
145
145
1.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.
147
147
148
148
To 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
150
150
default 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.
152
152
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 *
154
154
WHERE { ?s ?p ?o . }`:
155
155
156
- REQUEST:
156
+ ** REQUEST**
157
157
158
158
``` http
159
159
GET /data/?query=SELECT%20*%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20.%20%7D HTTP/1.1
160
160
Host: example.org
161
161
```
162
162
163
- RESPONSE:
163
+ ** RESPONSE**
164
164
165
165
``` http
166
166
HTTP/1.1 200 OK
@@ -207,10 +207,10 @@ to the following value:
207
207
` Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type" `
208
208
209
209
For 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 ` :
212
212
213
- REQUEST:
213
+ ** REQUEST**
214
214
215
215
``` http
216
216
POST / HTTP/1.1
@@ -223,7 +223,7 @@ Slug: data
223
223
<> <http://purl.org/dc/terms/title> "Basic container" .
224
224
```
225
225
226
- RESPONSE:
226
+ ** RESPONSE**
227
227
228
228
``` http
229
229
HTTP/1.1 201 Created
@@ -236,10 +236,10 @@ value:
236
236
` Link: <http://www.w3.org/ns/ldp#Resource>; rel="type" `
237
237
238
238
For 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 ` :
241
241
242
- REQUEST:
242
+ ** REQUEST**
243
243
244
244
``` http
245
245
POST / HTTP/1.1
@@ -252,22 +252,22 @@ Slug: test
252
252
<> <http://purl.org/dc/terms/title> "This is a test file" .
253
253
```
254
254
255
- RESPONSE:
255
+ ** RESPONSE**
256
256
257
257
``` http
258
258
HTTP/1.1 201 Created
259
259
```
260
260
261
261
More examples can be found in the LDP [ Primer document] ( http://www.w3.org/TR/ldp-primer/ ) .
262
262
263
- #### HTTP PUT to create
263
+ #### HTTP ` PUT ` to create
264
264
265
265
An 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 ` ).
269
269
270
- REQUEST:
270
+ ** REQUEST**
271
271
272
272
``` http
273
273
PUT /picture.jpg HTTP/1.1
@@ -276,23 +276,23 @@ Content-Type: image/jpeg
276
276
...
277
277
```
278
278
279
- RESPONSE :
279
+ ** RESPONSE**
280
280
281
281
``` http
282
282
HTTP/1.1 201 Created
283
283
```
284
284
285
285
Another 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
287
287
useful 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
289
289
this feature is defined in HTTP1.1
290
290
[ RFC2616] ( https://tools.ietf.org/html/rfc2616 ) , we decided to improve it
291
291
slightly by having servers create the full path to the resource (including
292
292
intermediate containers), if it didn't exist before. (If you're familiar with
293
293
the 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
296
296
day container when switching to a new month, it could send the following request
297
297
to create a new event resource called ` event1 ` :
298
298
@@ -314,25 +314,25 @@ missing intermediate resources -- containers for the month `05` and the day `01`
314
314
under the parent container ` /2015/ ` .
315
315
316
316
To 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.
319
319
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.*
323
323
324
324
#### Alternative: Using SPARQL
325
325
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
327
327
the 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 ` .
329
329
330
330
For 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 `
332
332
statement. Multiple statements (delimited by a ` ; ` ) can be sent in the same
333
- PATCH request.
333
+ ` PATCH ` request.
334
334
335
- REQUEST:
335
+ ** REQUEST**
336
336
337
337
``` http
338
338
PATCH /data/ HTTP/1.1
@@ -344,27 +344,30 @@ DELETE DATA { <> <http://purl.org/dc/terms/title> "Basic container" };
344
344
INSERT DATA { <> <http://purl.org/dc/terms/title> "My data container" }
345
345
```
346
346
347
- RESPONSE:
347
+ ** RESPONSE**
348
348
349
349
``` http
350
350
HTTP/1.1 200 OK
351
351
```
352
352
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.*
355
355
356
- ### Discovering server capabilities - the OPTIONS method
356
+ ### Discovering server capabilities - the ` OPTIONS ` method
357
357
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 ` ).
359
362
360
- REQUEST:
363
+ ** REQUEST**
361
364
362
365
``` http
363
- OPTIONS /data/ HTTP/1.1
366
+ OPTIONS * HTTP/1.1
364
367
Host: example.org
365
368
```
366
369
367
- RESPONSE:
370
+ ** RESPONSE**
368
371
369
372
``` http
370
373
HTTP/1.1 200 OK
@@ -375,4 +378,27 @@ Access-Control-Allow-Methods: OPTIONS, HEAD, GET, PATCH, POST, PUT, DELETE
375
378
Access-Control-Allow-Origin: *
376
379
Access-Control-Expose-Headers: User, Triples, Location, Link, Vary, Last-Modified, Content-Length
377
380
Allow: 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
+
378
404
```
0 commit comments