LDP-CoAP Mapping

LDP-CoAP mapping rule summary. Details about server restrictions can be found on the General Implementation Report page.

LDP-CoAP BASICS

Method Mandatory Supported in CoAP LDP-CoAP Mapping HTTP Response Code CoAP Response Code
GET YES YES GET 200 OK 2.05 Content
POST NO YES POST 201 Created 2.01 Created
PUT NO YES PUT 204 No Content 2.04 Changed
DELETE NO YES DELETE 204 No Content 2.02 Deleted
PATCH NO NO PUT ?ldp=patch 204 No Content 2.04 Changed
HEAD YES NO GET ?ldp=head 204 No Content 2.03 Valid
OPTIONS YES NO GET ?ldp=options 204 No Content 2.05 Content

HTTP-CoAP Headers Mapping

HTTP Header LPD-CoAP Mapping
Content-Type Content-Format (CT) CoAP option
Link (rel="type") Resource-Type (RT) Core Link format attribute, available through a CoAP discovery request
Allow, Accept-Post, Accept-Patch Not defined in CoAP, available in JSON format as body content of a LDP-CoAP Options request
Slug Title Core Link format attribute
Location Location-Path and Location-Query CoAP option

HTTP-CoAP refer Headers Mapping

HTTP Prefer Header LPD-CoAP Mapping
Prefer: return=representation; include="pref" ldp-incl=pref Core Link Format attribute
Prefer:return=representation; omit="pref" ldp-omit=pref Core Link Format attribute
Preference-Applied: return=representation pref returned using Location-Query CoAP option

LDP Resource Discovery [NEW]

  • CoRE Resource Discovery as reported in [RFC 6690]
  • CoAP GET request on a well-known resource: "/.well-known/core".
  • Retrieve LDP type (RT), Content-Format (CT) and Title for each resource.

Content-Format codes used in the following examples: text/plain (ct=0), text/turtle (ct=4), application/rdf-patch (ct=53)

								
</.well-known/core>,

</ldp-rs> 
	rt="http://www.w3.org/ns/ldp#RDFSource http://www.w3.org/ns/ldp#Resource"; 
	ct=4; title="ldp-rs",
	
</ldp-nr> 	
	rt="http://www.w3.org/ns/ldp#NonRDFSource http://www.w3.org/ns/ldp#Resource"; 
	ct=0; title="ldp-nr",

</ldp-bc> 	
	rt="http://www.w3.org/ns/ldp#BasicContainer http://www.w3.org/ns/ldp#Container http://www.w3.org/ns/ldp#Resource"; 
	ct=4; title="ldp-bc",

</ldp-dc> 	 
	rt="http://www.w3.org/ns/ldp#DirectContainer http://www.w3.org/ns/ldp#Container http://www.w3.org/ns/ldp#Resource"; 
	ct=4; title="ldp-dc",
	
</ldp-dc/tmp35> 	
	rt="http://purl.oclc.org/NET/ssnx/ssn#SensingDevice http://www.w3.org/ns/ldp#Resource"; 
	ct=4; title="Temperature Sensor TMP35",
	
</ldp-dc/tmp35/obs1>	
	rt="http://purl.oclc.org/NET/ssnx/ssn#Observation http://www.w3.org/ns/ldp#Resource";
	ct=4; title="Observation"
								
							


LDP Method: GET

  • HTTP Response Code 200 OK mapped with 2.05 Content CoAP code.
  • HTTP Header Content-Type mapped with Content-Format (CT) CoAP option.
  • HTTP Header Link (rel="type") mapped with Resource-Type (RT) Core Link format attribute and available through a CoAP discovery request.
  • HTTP Headers Allow, Accept-Post, Accept-Patch available through a LDP-CoAP Options request.

HTTP GET

								
GET /alice/ HTTP/1.1
Host: example.org
Accept: text/turtle

HTTP/1.1 200 OK 
Content-Type: text/turtle; charset=UTF-8
Link: <http://www.w3.org/ns/ldp#BasicContainer> rel="type", 
	<http://www.w3.org/ns/ldp#Resource> rel="type"
Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH
Accept-Post: text/turtle, application/ld+json, image/bmp, image/jpeg
Accept-Patch: text/ldpatch
Content-Length: 250
ETag: W/'123456789'
	
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
	
<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
  dcterms:title "Alice's data storage on the Web" .	
								
							

CoAP GET

								
GET coap://example.org/alice/ 
Accept: text/turtle

2.05 Content
Content-Format (ct): text/turtle 
ETag: W/'123456789'
	
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
	
<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
  dcterms:title "Alice's data storage on the Web" .	
								
							


LDP Method: POST

  • HTTP Header Slug mapped with Title Core Link format attribute.
  • HTTP Response Header Location mapped with Location-Path CoAP option.
  • HTTP Response Header Link (rel="type") mapped with Resource-Type (RT) Core Link format attribute and available through a CoAP discovery request.

HTTP POST

								
POST /alice/ HTTP/1.1
Host: example.org
Slug: foaf
Content-Type: text/turtle

@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<> a foaf:PersonalProfileDocument;
    foaf:primaryTopic <#me> ;
    dc:title "Alice's FOAF file" .

<#me> a foaf:Person;
    foaf:name "Alice Smith"  .

HTTP/1.1 201 Created
Location: http://example.org/alice/foaf
Link: <http://www.w3.org/ns/ldp#Resource> rel='type'
Content-Length: 0	
								
							

CoAP POST

								
POST coap://example.org/alice?title=foaf
Content-Format (ct): text/turtle 

@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<> a foaf:PersonalProfileDocument;
    foaf:primaryTopic <#me> ;
    dc:title "Alice's FOAF file" .

<#me> a foaf:Person;
    foaf:name "Alice Smith"  .

2.01 Created
Location-Path: coap://example.org/alice/foaf
								
							


LDP Method: PUT

  • HTTP Response Code 204 No Content mapped with 2.04 Changed CoAP code.
  • HTTP Response Header Link (rel="type") mapped with Resource-Type (RT) Core Link format attribute and available through a CoAP discovery request.
  • Method available in CoAP only for existing resources. To create a new LDP-CoAP resource, a POST request MUST BE used.

HTTP PUT

								
PUT /alice/foaf HTTP/1.1
Host: example.org
If-Match: W/"123454321"
Content-Type: text/turtle

@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<> a foaf:PersonalProfileDocument;
    foaf:primaryTopic <#me> ;
    dc:title "Alice's FOAF file" .

<#me> a foaf:Person;
    foaf:name "Alice Smith"  ;
    foaf:img <http://example.org/alice/avatar> .

HTTP/1.1 204 No Content 
Link: <http://www.w3.org/ns/ldp#Resource> rel="type" 	
								
							

CoAP PUT

								
PUT coap://example.org/alice/foaf
If-Match: W/"123454321"
Content-Format (ct): text/turtle

@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<> a foaf:PersonalProfileDocument;
    foaf:primaryTopic <#me> ;
    dc:title "Alice's FOAF file" .

<#me> a foaf:Person;
    foaf:name "Alice Smith"  ;
    foaf:img <http://example.org/alice/avatar> .

2.04 Changed
								
							


LDP Method: DELETE

  • HTTP Response Code 204 No Content mapped with 2.02 Deleted CoAP code.

HTTP DELETE

								
DELETE /alice/avatar HTTP/1.1
Host: example.org  

HTTP/1.1 204 No Content	
								
							

CoAP DELETE

								
DELETE coap://example.org/alice/avatar

2.02 Deleted
								
							


LDP Method: OPTIONS

  • OPTIONS method not defined in CoAP protocol. Mapped as a GET request with ldp=options parameter.
  • Allow, Accept-Post, Accept-Patch Header fields not defined in CoAP.
  • HTTP Header fields mapped as CoAP body content in JSON format.
  • LDP-CoAP Options method presents a 2.05 Content response code.

HTTP OPTIONS

								
OPTIONS /alice HTTP/1.1
Host: example.org  

HTTP/1.1 204 No Content
Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH
Accept-Post: text/turtle, application/ld+json, image/bmp, image/jpeg
Accept-Patch: text/ldpatch
Link: <http://www.w3.org/ns/ldp#BasicContainer> rel="type", 
	<http://www.w3.org/ns/ldp#Resource> rel="type"     
								
							

CoAP OPTIONS

								
GET coap://example.org/alice?ldp=options

2.05 Content
Content-Format (ct): application/json 
{
  "Allow": ["OPTIONS", "HEAD", "GET", "POST", "PUT", "PATCH"],
  "Accept-Post": [ "text/turtle", "application/ld+json", 
		"image/bmp", "image/jpeg"],
  "Accept-Patch": "text/ldpatch"
}
								
							


LDP Method: HEAD

  • HEAD method not defined in CoAP protocol. Mapped as a GET request with ldp=head parameter.
  • HTTP Header Allow, Accept-Post, Accept-Patch available through a LDP-CoAP Options request.
  • HTTP Response Code 204 No Content mapped with 2.03 Valid CoAP code.

HTTP HEAD

								
OPTIONS /alice HTTP/1.1
Host: example.org  

HTTP/1.1 204 No Content
Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH
Link: <http://www.w3.org/ns/ldp#BasicContainer> rel="type", 
	<http://www.w3.org/ns/ldp#Resource> rel="type"    
ETag: W/'123456789' 
Content-Type: text/turtle
								
							

CoAP HEAD

								
GET coap://example.org/alice?ldp=head

2.03 Valid
Content-Format (ct): text/turtle 
ETag: W/'123456789'
								
							


LDP Method: PATCH

  • PATCH method not defined in CoAP protocol. Mapped as a PUT request with ldp=patch parameter.
  • HTTP Response Code 204 No Content mapped with 2.04 Changed CoAP code.
  • Implementing RDF-Patch specification.

HTTP PATCH

								
PATCH /bob HTTP/1.1
Host: example.org
Content-Type: application/rdf-patch
If-Match: W/"123454321"

@prefix  foaf: <http://xmlns.com/foaf/0.1/> .
A <> foaf:knows <http://example.org/alice> .

HTTP/1.1 204 No Content 
Link: <http://www.w3.org/ns/ldp#Resource> rel="type" 
								
							

CoAP PATCH

								
PUT coap://example.org/bob?ldp=patch 
If-Match: W/"123454321"
Content-Format (ct): application/rdf-patch

@prefix  foaf: <http://xmlns.com/foaf/0.1/> .
A <> foaf:knows <http://example.org/alice> .

2.04 Changed