idnits 2.17.1 draft-ietf-core-http-mapping-17.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (November 28, 2016) is 2668 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '0' on line 1577 -- Looks like a reference, but probably isn't: '1' on line 1578 ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) ** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7232 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7235 (Obsoleted by RFC 9110) == Outdated reference: A later version (-10) exists of draft-ietf-core-links-json-06 == Outdated reference: A later version (-28) exists of draft-ietf-core-resource-directory-09 -- Obsolete informational reference (is this intentional?): RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 7049 (Obsoleted by RFC 8949) Summary: 5 errors (**), 0 flaws (~~), 4 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 CoRE Working Group A. Castellani 3 Internet-Draft University of Padova 4 Intended status: Standards Track S. Loreto 5 Expires: June 1, 2017 Ericsson 6 A. Rahman 7 InterDigital Communications, LLC 8 T. Fossati 9 Nokia 10 E. Dijk 11 Philips Lighting 12 November 28, 2016 14 Guidelines for HTTP-to-CoAP Mapping Implementations 15 draft-ietf-core-http-mapping-17 17 Abstract 19 This document provides reference information for implementing a 20 cross-protocol network proxy that performs translation from the HTTP 21 protocol to CoAP (Constrained Application Protocol). This will 22 enable an HTTP client to access resources on a CoAP server through 23 the proxy. This document describes how an HTTP request is mapped to 24 a CoAP request, and then how a CoAP response is mapped back to an 25 HTTP response. This includes guidelines for status code, URI, and 26 media type mappings, as well as additional interworking advice. 28 Status of This Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at http://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on June 1, 2017. 45 Copyright Notice 47 Copyright (c) 2016 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents 52 (http://trustee.ietf.org/license-info) in effect on the date of 53 publication of this document. Please review these documents 54 carefully, as they describe your rights and restrictions with respect 55 to this document. Code Components extracted from this document must 56 include Simplified BSD License text as described in Section 4.e of 57 the Trust Legal Provisions and are provided without warranty as 58 described in the Simplified BSD License. 60 Table of Contents 62 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 63 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 64 3. HTTP-to-CoAP Proxy . . . . . . . . . . . . . . . . . . . . . 5 65 4. Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . 6 66 5. URI Mapping . . . . . . . . . . . . . . . . . . . . . . . . . 7 67 5.1. URI Terminology . . . . . . . . . . . . . . . . . . . . . 8 68 5.2. Null Mapping . . . . . . . . . . . . . . . . . . . . . . 8 69 5.3. Default Mapping . . . . . . . . . . . . . . . . . . . . . 8 70 5.3.1. Optional Scheme Omission . . . . . . . . . . . . . . 9 71 5.3.2. Encoding Caveats . . . . . . . . . . . . . . . . . . 9 72 5.4. URI Mapping Template . . . . . . . . . . . . . . . . . . 9 73 5.4.1. Simple Form . . . . . . . . . . . . . . . . . . . . . 10 74 5.4.2. Enhanced Form . . . . . . . . . . . . . . . . . . . . 11 75 5.5. Discovery . . . . . . . . . . . . . . . . . . . . . . . . 13 76 5.5.1. Examples . . . . . . . . . . . . . . . . . . . . . . 13 77 6. Media Type Mapping . . . . . . . . . . . . . . . . . . . . . 15 78 6.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 15 79 6.2. 'application/coap-payload' Media Type . . . . . . . . . . 16 80 6.3. Loose Media Type Mapping . . . . . . . . . . . . . . . . 17 81 6.4. Media Type to Content Format Mapping Algorithm . . . . . 18 82 6.5. Content Transcoding . . . . . . . . . . . . . . . . . . . 19 83 6.5.1. General . . . . . . . . . . . . . . . . . . . . . . . 19 84 6.5.2. CoRE Link Format . . . . . . . . . . . . . . . . . . 20 85 6.5.3. Diagnostic Messages . . . . . . . . . . . . . . . . . 20 86 7. Response Code Mapping . . . . . . . . . . . . . . . . . . . . 21 87 8. Additional Mapping Guidelines . . . . . . . . . . . . . . . . 23 88 8.1. Caching and Congestion Control . . . . . . . . . . . . . 23 89 8.2. Cache Refresh via Observe . . . . . . . . . . . . . . . . 24 90 8.3. Use of CoAP Blockwise Transfer . . . . . . . . . . . . . 24 91 8.4. CoAP Multicast . . . . . . . . . . . . . . . . . . . . . 25 92 8.5. Timeouts . . . . . . . . . . . . . . . . . . . . . . . . 26 94 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 26 95 9.1. New 'core.hc' Resource Type . . . . . . . . . . . . . . . 26 96 9.2. New 'coap-payload' Internet Media Type . . . . . . . . . 26 97 10. Security Considerations . . . . . . . . . . . . . . . . . . . 28 98 10.1. Multicast . . . . . . . . . . . . . . . . . . . . . . . 29 99 10.2. Traffic Overflow . . . . . . . . . . . . . . . . . . . . 29 100 10.3. Handling Secured Exchanges . . . . . . . . . . . . . . . 30 101 10.4. URI Mapping . . . . . . . . . . . . . . . . . . . . . . 30 102 11. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 31 103 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 31 104 12.1. Normative References . . . . . . . . . . . . . . . . . . 31 105 12.2. Informative References . . . . . . . . . . . . . . . . . 33 106 Appendix A. Media Type Mapping Source Code . . . . . . . . . . . 34 107 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 38 108 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 43 110 1. Introduction 112 CoAP (Constrained Application Protocol) [RFC7252] has been designed 113 with the twofold aim to be an application protocol specialized for 114 constrained environments and to be easily used in Representational 115 State Transfer (REST) [Fielding] based architectures such as the Web. 116 The latter goal has led to defining CoAP to easily interoperate with 117 HTTP [RFC7230] through an intermediary proxy which performs cross- 118 protocol conversion. 120 Section 10 of [RFC7252] describes the fundamentals of the CoAP-to- 121 HTTP and the HTTP-to-CoAP cross-protocol mapping process. However, 122 [RFC7252] focuses on the basic mapping of request methods and simple 123 response code mapping between HTTP and CoAP, while leaving many 124 details of the cross-protocol proxy for future definition. 125 Therefore, a primary goal of this document is to define a consistent 126 set of guidelines that an HTTP-to-CoAP proxy implementation should 127 adhere to. The key benefit to adhering to such guidelines is to 128 reduce variation between proxy implementations, thereby increasing 129 interoperability between an HTTP client and a CoAP server independent 130 of the proxy that implements the cross-protocol mapping. (For 131 example, a proxy conforming to these guidelines made by vendor A can 132 be easily replaced by a proxy from vendor B that also conforms to the 133 guidelines without breaking API semantics.) 135 This document describes HTTP mappings that apply to protocol elements 136 defined in the base CoAP specification [RFC7252]. It is up to CoAP 137 protocol extensions (new methods, response codes, options, content- 138 formats) to describe their own HTTP mappings, if applicable. 140 The rest of this document is organized as follows: 142 o Section 2 defines proxy terminology; 144 o Section 3 introduces the HTTP-to-CoAP proxy; 146 o Section 4 lists use cases in which HTTP clients need to contact 147 CoAP servers; 149 o Section 5 introduces a null, default, and advanced HTTP-to-CoAP 150 URI mapping syntax; 152 o Section 6 describes how to map HTTP media types to CoAP content 153 formats and vice versa; 155 o Section 7 describes how to map CoAP responses to HTTP responses; 157 o Section 8 describes additional mapping guidelines related to 158 caching, congestion, timeouts, etc.; 160 o Section 10 discusses possible security impact of HTTP-to-CoAP 161 protocol mapping. 163 2. Terminology 165 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 166 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 167 "OPTIONAL" in this document are to be interpreted as described in 168 [RFC2119]. 170 This specification requires readers to be familiar with the 171 vocabulary and concepts discussed in [RFC7228], in particular, the 172 terms "Constrained Nodes" and "Constrained Networks". In addition, 173 this specification makes use of the following terms: 175 HC Proxy 176 A proxy performing a cross-protocol mapping, in the context of 177 this document an HTTP-to-CoAP (HC) mapping. Specifically, the HC 178 Proxy acts as an HTTP server and a CoAP client. The HC Proxy can 179 take on the role of a Forward, Reverse or Interception Proxy. 181 Forward Proxy (or Forward HC Proxy) 182 A message forwarding agent that is selected by the HTTP client, 183 usually via local configuration rules, to receive requests for 184 some type(s) of absolute URI and to attempt to satisfy those 185 requests via translation to the protocol indicated by the 186 absolute URI. The user decides (is willing) to use the proxy as 187 the forwarding/de-referencing agent for a predefined subset of 188 the URI space. In [RFC7230] this is called a Proxy. [RFC7252] 189 defines Forward-Proxy similarly. 191 Reverse Proxy (or Reverse HC Proxy) 192 As in [RFC7230], a receiving agent that acts as a layer above 193 some other server(s) and translates the received requests to the 194 underlying server's protocol. A Reverse HC Proxy behaves as an 195 origin (HTTP) server on its connection from the HTTP client. The 196 HTTP client uses the "origin-form" (Section 5.3.1 of [RFC7230]) 197 as a request-target URI. (Note that a Reverse Proxy appears to 198 an HTTP client as an origin server while a Forward Proxy does 199 not. So, when communicating with a Reverse Proxy a client may be 200 unaware it is communicating with a proxy at all.) 202 Interception Proxy (or Interception HC Proxy) 203 As in [RFC3040], a proxy that receives inbound HTTP traffic flows 204 through the process of traffic redirection, transparent to the 205 HTTP client. 207 3. HTTP-to-CoAP Proxy 209 An HC Proxy is accessed by an HTTP client that needs to fetch a 210 resource on a CoAP server. The HC Proxy handles the HTTP request by 211 mapping it to the equivalent CoAP request, which is then forwarded to 212 the appropriate CoAP server. The received CoAP response is then 213 mapped to an appropriate HTTP response and finally sent back to the 214 originating HTTP client. 216 Section 10.2 of [RFC7252] defines basic normative requirements on 217 HTTP-to-CoAP mapping. This document provides additional details and 218 guidelines for the implementation of an HC Proxy. 220 Constrained Network 221 .-------------------. 222 / .------. \ 223 / | CoAP | \ 224 / |server| \ 225 || '------' || 226 || || 227 .--------. HTTP Request .------------. CoAP Req .------. || 228 | HTTP |---------------->|HTTP-to-CoAP|----------->| CoAP | || 229 | Client |<----------------| Proxy |<-----------|Server| || 230 '--------' HTTP Response '------------' CoAP Resp '------' || 231 || || 232 || .------. || 233 || | CoAP | || 234 \ |server| .------. / 235 \ '------' | CoAP | / 236 \ |server| / 237 \ '------' / 238 '-----------------' 240 Figure 1: HTTP-To-CoAP Proxy Deployment Scenario 242 Figure 1 illustrates an example deployment scenario. There, an HC 243 Proxy is located at the boundary of the Constrained Network domain 244 and acts as an Application Layer Gateway (ALG) that allows only a 245 very specific type of traffic (i.e., authorized inbound HTTP requests 246 and their associated outbound CoAP responses) to pass through. All 247 other kinds of traffic are segregated within the respective network 248 segments. 250 4. Use Cases 252 To illustrate a few situations in which HTTP to CoAP protocol 253 translation may be used, three use cases are described below. 255 1. Legacy building control application without CoAP: A building 256 control application that uses HTTP but not CoAP can check the 257 status of CoAP sensors and/or control actuators via an HC Proxy. 259 2. Making sensor data available to 3rd parties on the Web: For 260 demonstration or public interest purposes, an HC Proxy may be 261 configured to expose the contents of a CoAP sensor to the world 262 via the web (HTTP and/or HTTPS). Some sensors may only accept 263 secure 'coaps' requests, therefore the proxy is configured to 264 translate requests to those devices accordingly. The HC Proxy is 265 furthermore configured to only pass through GET requests in order 266 to protect the constrained network. 268 3. Smartphone and home sensor: A smartphone can access directly a 269 CoAP home sensor using a mutually authenticated 'https' request, 270 provided its home router runs an HC Proxy and is configured with 271 the appropriate certificate. An HTML5 [W3C.REC-html5-20141028] 272 application on the smartphone can provide a friendly UI using the 273 standard (HTTP) networking functions of HTML5. 275 A key point in the above use cases is the expected nature of the URI 276 to be used by the HTTP client initiating the HTTP request to the HC 277 Proxy. Specifically, in use case #1, there will be no 'coap' or 278 'coaps' related information embedded in the HTTP URI as it is a 279 legacy HTTP client sending the request. Use case #2 is also expected 280 to be similar. In contrast, in use case #3, it is likely that the 281 HTTP client will specifically embed 'coap' or 'coaps' related 282 information in the HTTP URI of the HTTP request to the HC Proxy. 284 5. URI Mapping 286 Though, in principle, a CoAP URI could be directly used by an HTTP 287 client to de-reference a CoAP resource through an HC Proxy, the 288 reality is that all major web browsers, networking libraries and 289 command line tools do not allow making HTTP requests using URIs with 290 a scheme 'coap' or 'coaps'. 292 Thus, there is a need for web applications to embed or "pack" a CoAP 293 URI into an HTTP URI so that it can be (non-destructively) 294 transported from the HTTP client to the HC Proxy. The HC Proxy can 295 then "unpack" the CoAP URI and finally de-reference it via a CoAP 296 request to the target Server. 298 URI Mapping is the term used in this document to describe the process 299 through which the URI of a CoAP resource is transformed into an HTTP 300 URI so that: 302 o The requesting HTTP client can handle it; 304 o The receiving HC Proxy can extract the intended CoAP URI 305 unambiguously. 307 To this end, the remainder of this section will identify: 309 o The default mechanism to map a CoAP URI into an HTTP URI; 311 o The URI template format to express a class of CoAP-HTTP URI 312 mapping functions; 314 o The discovery mechanism based on CoRE Link Format [RFC6690] 315 through which clients of an HC Proxy can dynamically learn about 316 the supported URI Mapping Template(s), as well as the URI where 317 the HC Proxy function is anchored. 319 5.1. URI Terminology 321 In the remainder of this section, the following terms will be used 322 with a distinctive meaning: 324 HC Proxy URI: 325 URI which refers to the HC Proxy function. It conforms to 326 syntax defined in Section 2.7 of [RFC7230]. 328 Target CoAP URI: 329 URI which refers to the (final) CoAP resource that has to be 330 de-referenced. It conforms to syntax defined in Section 6 of 331 [RFC7252]. Specifically, its scheme is either 'coap' or 332 'coaps'. 334 Hosting HTTP URI: 335 URI that conforms to syntax in Section 2.7 of [RFC7230]. Its 336 authority component refers to an HC Proxy, whereas path and/ 337 or query component(s) embed the information used by an HC 338 Proxy to extract the Target CoAP URI. 340 5.2. Null Mapping 342 The null mapping is the case where there is no Target CoAP URI 343 appended to the HC Proxy URI. In other words, it is a "pure" HTTP 344 URI that is sent to the HC Proxy. This would typically occur in 345 situations like Use Case #1 described in Section 4, and the Proxy 346 would typically be a Reverse Proxy. In this scenario, the HC Proxy 347 will determine through its own private algorithms what the Target 348 CoAP URI should be. 350 5.3. Default Mapping 352 The default mapping is for the Target CoAP URI to be appended as-is 353 (with the only caveat discussed in Section 5.3.2) to the HC Proxy 354 URI, to form the Hosting HTTP URI. This is the Effective Request URI 355 (see Section 5.5 of [RFC7230]) that will then be sent by the HTTP 356 client in the HTTP request to the HC Proxy. 358 For example: given an HC Proxy URI https://p.example.com/hc/ and a 359 Target CoAP URI coap://s.example.com/light, the resulting Hosting 360 HTTP URI would be https://p.example.com/hc/coap://s.example.com/ 361 light. 363 Provided a correct Target CoAP URI, the Hosting HTTP URI resulting 364 from the default mapping will be a syntactically valid HTTP URI. 365 Furthermore, the Target CoAP URI can always be extracted 366 unambiguously from the Hosting HTTP URI. 368 There is no default for the HC Proxy URI. Therefore, it is either 369 known in advance, e.g., as a configuration preset, or dynamically 370 discovered using the mechanism described in Section 5.5. 372 The default URI mapping function SHOULD be implemented and SHOULD be 373 activated by default in an HC Proxy, unless there are valid reasons 374 (e.g., application specific) to use a different mapping function. 376 5.3.1. Optional Scheme Omission 378 When constructing a Hosting HTTP URI by embedding a Target CoAP URI, 379 the scheme (i.e., 'coap' or 'coaps'), the scheme component delimiter 380 (":"), and the double slash ("//") preceding the authority MAY be 381 omitted if a local default - not defined by this document - applies. 382 If no prior mutual agreement exists between the client and the HC 383 Proxy, then a Target CoAP URI without the scheme component is 384 syntactically incorrect, and therefore: 386 o It MUST NOT be emitted by clients; 388 o It MUST elicit a suitable client error status (i.e., 4xx) by the 389 HC Proxy. 391 5.3.2. Encoding Caveats 393 When the authority of the Target CoAP URI is given as an IPv6address, 394 then the surrounding square brackets must be percent-encoded in the 395 Hosting HTTP URI, in order to comply with the syntax defined in 396 Section 3.3. of [RFC3986] for a URI path segment. E.g.: 397 coap://[2001:db8::1]/light?on becomes 398 https://p.example.com/hc/coap://%5B2001:db8::1%5D/light?on. (Note 399 that the percent-encoded square brackets shall be reverted to their 400 non-percent-encoded form when the HC Proxy unpacks the Target CoAP 401 URI.) 403 Everything else can be safely copied verbatim from the Target CoAP 404 URI to the Hosting HTTP URI. 406 5.4. URI Mapping Template 408 This section defines a format for the URI template [RFC6570] used by 409 an HC Proxy to inform its clients about the expected syntax for the 410 Hosting HTTP URI. This will then be used by the HTTP client to 411 construct the Effective Request URI to be sent in the HTTP request to 412 the HC Proxy. 414 When instantiated, a URI Mapping Template is always concatenated to 415 an HC Proxy URI provided by the HC Proxy via discovery (see 416 Section 5.5), or by other means. 418 A simple form (Section 5.4.1) and an enhanced form (Section 5.4.2) 419 are provided to fit different users' requirements. 421 Both forms are expressed as level 2 URI templates [RFC6570] to take 422 care of the expansion of values that are allowed to include reserved 423 URI characters. The syntax of all URI formats is specified in this 424 section in Augmented Backus-Naur Form (ABNF) [RFC5234]. 426 5.4.1. Simple Form 428 The simple form MUST be used for mappings where the Target CoAP URI 429 is going to be copied (using rules of Section 5.3.2) at some fixed 430 position into the Hosting HTTP URI. 432 The "tu" template variable is intended to be used in a template 433 definition to represent a Target CoAP URI: 435 tu = [ ( "coap:" / "coaps:" ) "//" ] host [ ":" port ] path-abempty 436 [ "?" query ] 438 Note that the same considerations as in Section 5.3.1 apply, in that 439 the CoAP scheme may be omitted from the Hosting HTTP URI. 441 5.4.1.1. Examples 443 All the following examples (given as a specific URI mapping template, 444 a Target CoAP URI, and the produced Hosting HTTP URI) use 445 https://p.example.com/hc/ as the HC Proxy URI. Note that these 446 examples all define mapping templates that deviate from the default 447 template of Section 5.3 in order to illustrate the use of the above 448 template variables. 450 1. Target CoAP URI is a query argument of the Hosting HTTP URI: 452 ?target_uri={+tu} 454 coap://s.example.com/light 456 => https://p.example.com/hc/?target_uri=coap://s.example.com/light 458 whereas 460 coaps://s.example.com/light 462 => https://p.example.com/hc/?target_uri=coaps://s.example.com/light 464 2. Target CoAP URI in the path component of the Hosting HTTP URI: 466 forward/{+tu} 468 coap://s.example.com/light 470 => https://p.example.com/hc/forward/coap://s.example.com/light 472 whereas 474 coaps://s.example.com/light 476 => https://p.example.com/hc/forward/coaps://s.example.com/light 478 3. Target CoAP URI is a query argument of the Hosting HTTP URI; 479 client decides to omit the scheme because a default is agreed 480 beforehand between client and proxy: 482 ?coap_uri={+tu} 484 coap://s.example.com/light 486 => https://p.example.com/hc/?coap_uri=s.example.com/light 488 5.4.2. Enhanced Form 490 The enhanced form can be used to express more sophisticated mappings 491 of the Target CoAP URI into the Hosting HTTP URI, i.e., mappings that 492 do not fit into the simple form. 494 There MUST be at most one instance of each of the following template 495 variables in a template definition: 497 s = "coap" / "coaps" ; from [RFC7252], Sections 6.1 and 6.2 498 hp = host [":" port] ; from [RFC3986], Sections 3.2.2 and 3.2.3 499 p = path-abempty ; from [RFC3986], Section 3.3 500 q = query ; from [RFC3986], Section 3.4 501 qq = [ "?" query ] ; qq is empty if and only if 'query' is empty 503 The qq form is used when the path and the (optional) query components 504 are to be copied verbatim from the Target CoAP URI into the Hosting 505 HTTP URI, i.e., as "{+p}{+qq}". Instead, the q form is used when the 506 query and path are mapped as separate entities, e.g., as in 507 "coap_path={+p}&coap_query={+q}". 509 5.4.2.1. Examples 511 All the following examples (given as a specific URI mapping template, 512 a Target CoAP URI, and the produced Hosting HTTP URI) use 513 https://p.example.com/hc/ as the HC Proxy URI. 515 1. Target CoAP URI components in path segments, and optional query 516 in query component: 518 {+s}/{+hp}{+p}{+qq} 520 coap://s.example.com/light 522 => https://p.example.com/hc/coap/s.example.com/light 524 whereas 526 coap://s.example.com/light?on 528 => https://p.example.com/hc/coap/s.example.com/light?on 530 2. Target CoAP URI components split in individual query arguments: 532 ?s={+s}&hp={+hp}&p={+p}&q={+q} 534 coap://s.example.com/light 536 => https://p.example.com/hc/?s=coap&hp=s.example.com&p=/light&q= 538 whereas 540 coaps://s.example.com/light?on 542 => https://p.example.com/hc/?s=coaps&hp=s.example.com&p=/light&q=on 544 5.5. Discovery 546 In order to accommodate site-specific needs while allowing third 547 parties to discover the proxy function, the HC Proxy SHOULD publish 548 information related to the location and syntax of the HC Proxy 549 function using the CoRE Link Format [RFC6690] interface. 551 To this aim a new Resource Type, "core.hc", is defined in this 552 document. It can be used as the value for the "rt" attribute in a 553 query to the /.well-known/core in order to locate the URI where the 554 HC Proxy function is anchored, i.e., the HC Proxy URI. 556 Along with it, the new target attribute "hct" is defined in this 557 document. This attribute MAY be returned in a "core.hc" link to 558 provide the URI Mapping Template associated with the mapping 559 resource. The default template given in Section 5.3, i.e., {+tu}, 560 MUST be assumed if no "hct" attribute is found in the returned link. 561 If a "hct" attribute is present in the returned link, then a client 562 MUST use it to create the Hosting HTTP URI. 564 The URI mapping SHOULD be discoverable (as specified in [RFC6690]) on 565 both the HTTP and the CoAP side of the HC Proxy, with one important 566 difference: on the CoAP side the link associated with the "core.hc" 567 resource needs an explicit anchor referring to the HTTP origin 568 [RFC6454], while on the HTTP interface the link context is already 569 the HTTP origin carried in the request's Host header, and doesn't 570 have to be made explicit. 572 5.5.1. Examples 574 o The first example exercises the CoAP interface and assumes that 575 the default template, {+tu}, is used. For example, a smartphone 576 may discover the public HC Proxy before leaving the home network. 577 Then when outside the home network, the smartphone will be able to 578 query the appropriate home sensor. 580 Req: GET coap://[ff02::1]/.well-known/core?rt=core.hc 582 Res: 2.05 Content 583 ;anchor="https://p.example.com";rt="core.hc" 585 o The second example - also on the CoAP side of the HC Proxy - uses 586 a custom template, i.e., one where the CoAP URI is carried inside 587 the query component, thus the returned link carries the URI 588 template to be used in an explicit "hct" attribute: 590 Req: GET coap://[ff02::1]/.well-known/core?rt=core.hc 592 Res: 2.05 Content 593 ;anchor="https://p.example.com"; 594 rt="core.hc";hct="?uri={+tu}" 596 On the HTTP side, link information can be serialized in more than one 597 way: 599 o using the 'application/link-format' content type: 601 Req: GET /.well-known/core?rt=core.hc HTTP/1.1 602 Host: p.example.com 604 Res: HTTP/1.1 200 OK 605 Content-Type: application/link-format 606 Content-Length: 18 608 ;rt="core.hc" 610 o using the 'application/link-format+json' content type as defined 611 in [I-D.ietf-core-links-json]: 613 Req: GET /.well-known/core?rt=core.hc HTTP/1.1 614 Host: p.example.com 616 Res: HTTP/1.1 200 OK 617 Content-Type: application/link-format+json 618 Content-Length: 31 620 [{"href":"/hc/","rt":"core.hc"}] 622 o using the Link header: 624 Req: GET /.well-known/core?rt=core.hc HTTP/1.1 625 Host: p.example.com 627 Res: HTTP/1.1 200 OK 628 Link: ;rt="core.hc" 630 6. Media Type Mapping 632 6.1. Overview 634 An HC Proxy needs to translate HTTP media types (Section 3.1.1.1 of 635 [RFC7231]) and content encodings (Section 3.1.2.2 of [RFC7231]) into 636 CoAP content formats (Section 12.3 of [RFC7252]) and vice versa. 638 Media type translation can happen in GET, PUT or POST requests going 639 from HTTP to CoAP, and in 2.xx (i.e., successful) responses going 640 from CoAP to HTTP. Specifically, PUT and POST need to map both the 641 Content-Type and Content-Encoding HTTP headers into a single CoAP 642 Content-Format option, whereas GET needs to map Accept and Accept- 643 Encoding HTTP headers into a single CoAP Accept option. To generate 644 the HTTP response, the CoAP Content-Format option is mapped back to a 645 suitable HTTP Content-Type and Content-Encoding combination. 647 An HTTP request carrying a Content-Type and Content-Encoding 648 combination which the HC Proxy is unable to map to an equivalent CoAP 649 Content-Format, SHALL elicit a 415 (Unsupported Media Type) response 650 by the HC Proxy. 652 On the content negotiation side, failure to map Accept and Accept-* 653 headers SHOULD be silently ignored: the HC Proxy SHOULD therefore 654 forward as a CoAP request with no Accept option. The HC Proxy thus 655 disregards the Accept/Accept-* header fields by treating the response 656 as if it is not subject to content negotiation, as mentioned in 657 Sections 5.3.* of [RFC7231]. However, an HC Proxy implementation is 658 free to attempt mapping a single Accept header in a GET request to 659 multiple CoAP GET requests, each with a single Accept option, which 660 are then tried in sequence until one succeeds. Note that an HTTP 661 Accept */* MUST be mapped to a CoAP request without Accept option. 663 While the CoAP to HTTP direction has always a well-defined mapping 664 (with the exception examined in Section 6.2), the HTTP to CoAP 665 direction is more problematic because the source set, i.e., 666 potentially 1000+ IANA registered media types, is much bigger than 667 the destination set, i.e., the mere 6 values initially defined in 668 Section 12.3 of [RFC7252]. 670 Depending on the tight/loose coupling with the application(s) for 671 which it proxies, the HC Proxy could implement different media type 672 mappings. 674 When tightly coupled, the HC Proxy knows exactly which content 675 formats are supported by the applications, and can be strict when 676 enforcing its forwarding policies in general, and the media type 677 mapping in particular. 679 On the other hand, when the HC Proxy is a general purpose ALG, being 680 too strict could significantly reduce the amount of traffic that it 681 would be able to successfully forward. In this case, the "loose" 682 media type mapping detailed in Section 6.3 MAY be implemented. 684 The latter grants more evolution of the surrounding ecosystem, at the 685 cost of allowing more attack surface. In fact, as a result of such 686 strategy, payloads would be forwarded more liberally across the 687 unconstrained/constrained network boundary of the communication path. 689 6.2. 'application/coap-payload' Media Type 691 If the HC Proxy receives a CoAP response with a Content-Format that 692 it does not recognize (e.g., because the value has been registered 693 after the proxy has been deployed, or the CoAP server uses an 694 experimental value which is not registered), then the HC Proxy SHALL 695 return a generic "application/coap-payload" media type with numeric 696 parameter "cf" as defined in Section 9.2. 698 For example, the CoAP content format '60' ("application/cbor") would 699 be represented by "application/coap-payload;cf=60", if the HC Proxy 700 doesn't recognize the content format '60'. 702 A HTTP client may use the media type "application/coap-payload" as a 703 means to send a specific content format to a CoAP server via an HC 704 Proxy if the client has determined that the HC Proxy does not 705 directly support the type mapping it needs. This case may happen 706 when dealing for example with newly registered, yet to be registered, 707 or experimental CoAP content formats. However, unless explicitly 708 configured to allow pass-through of unknown content formats, the HC 709 Proxy SHOULD NOT forward requests carrying a Content-Type or Accept 710 header with an "application/coap-payload", and return an appropriate 711 client error instead. 713 6.3. Loose Media Type Mapping 715 By structuring the type information in a super-class (e.g., "text") 716 followed by a finer grained sub-class (e.g., "html"), and optional 717 parameters (e.g., "charset=utf-8"), Internet media types provide a 718 rich and scalable framework for encoding the type of any given 719 entity. 721 This approach is not applicable to CoAP, where Content Formats 722 conflate an Internet media type (potentially with specific 723 parameters) and a content encoding into one small integer value. 725 To remedy this loss of flexibility, we introduce the concept of a 726 "loose" media type mapping, where media types that are 727 specializations of a more generic media type can be aliased to their 728 super-class and then mapped (if possible) to one of the CoAP content 729 formats. For example, "application/soap+xml" can be aliased to 730 "application/xml", which has a known conversion to CoAP. In the 731 context of this "loose" media type mapping, "application/octet- 732 stream" can be used as a fallback when no better alias is found for a 733 specific media type. 735 Table 1 defines the default lookup table for the "loose" media type 736 mapping. It is expected that an implementation can refine it either 737 given application-specific knowledge, or because new Content-Formats 738 are defined. Given an input media type, the table returns its best 739 generalized media type using the most specific match i.e., the table 740 entries are compared to the input in top to bottom order until an 741 entry matches. 743 +-----------------------------+--------------------------+ 744 | Internet media type pattern | Generalized media type | 745 +-----------------------------+--------------------------+ 746 | application/*+xml | application/xml | 747 | application/*+json | application/json | 748 | application/*+cbor | application/cbor | 749 | text/xml | application/xml | 750 | text/* | text/plain | 751 | */* | application/octet-stream | 752 +-----------------------------+--------------------------+ 754 Table 1: Media type generalization lookup table 756 The "loose" media type mapping is an OPTIONAL feature. 757 Implementations supporting this kind of mapping should provide a 758 flexible way to define the set of media type generalizations allowed. 760 6.4. Media Type to Content Format Mapping Algorithm 762 This section defines the algorithm used to map an HTTP Internet media 763 type to its correspondent CoAP content format; it can be used as a 764 building block for translating HTTP Content-Type and Accept headers 765 into CoAP Content-Format and Accept Options. 767 The algorithm uses an IANA-maintained table, "CoAP Content-Formats", 768 as established by Section 12.3 of [RFC7252] plus, possibly, any 769 locally defined extension of it. Optionally, the table and lookup 770 mechanism described in Section 6.3 can be used if the implementation 771 chooses so. 773 Note that the algorithm assumes an "identity" Content-Encoding and 774 expects the resource body has been already successfully content- 775 decoded or transcoded to the desired format. 777 In the following (Figure 2): 779 o media_type is the media type to translate; 781 o coap_cf_registry is a lookup table matching the CoAP Content 782 Format Registry; 784 o loose_mapper is an optional lookup table describing the loose 785 media type mappings (e.g., the one defined in Table 1); 787 The full source code is provided in Appendix A. 789 def mt2cf(media_type, encoding=None, 790 coap_cf_registry=CoAPContentFormatRegistry(), 791 loose_mapper=None): 792 """Return a CoAP Content-Format given an Internet Media Type and 793 its optional encoding. The current (as of 2016/10/24) CoAP 794 Content Format Registry is supplied by default. An optional 795 'loose-mapping' implementation can be supplied by the caller.""" 796 assert media_type is not None 797 assert coap_cf_registry is not None 799 # Lookup the CoAP Content-Formats registry 800 content_format = coap_cf_registry.lookup(media_type, encoding) 802 # If an exact match is not found and a loose mapper has been 803 # supplied, try to use it to get a media type with which to 804 # re-try the CoAP Content-Formats registry lookup. 805 if content_format is None and loose_mapper is not None: 806 content_format = coap_cf_registry.lookup( 807 loose_mapper.lookup(media_type), encoding) 809 return content_format 811 Figure 2 813 6.5. Content Transcoding 815 6.5.1. General 817 Payload content transcoding is an OPTIONAL feature. Implementations 818 supporting this feature should provide a flexible way to define the 819 set of transcodings allowed. 821 The HC Proxy might decide to transcode the received representation to 822 a different (compatible) format when an optimized version of a 823 specific format exists. For example, a XML-encoded resource could be 824 transcoded to Efficient XML Interchange (EXI) format, or a JSON- 825 encoded resource into CBOR [RFC7049], effectively achieving 826 compression without losing any information. 828 However, there are a few important factors to keep in mind when 829 enabling a transcoding function: 831 1. Maliciously crafted inputs coming from the HTTP side might 832 inflate in size (see for example Section 4.2 of [RFC7049]), 833 therefore creating a security threat for both the HC Proxy and 834 the target resource; 836 2. Transcoding can lose information in non-obvious ways. For 837 example, encoding a XML document using schema-informed EXI 838 encoding leads to a loss of information when the destination does 839 not know the exact schema version used by the encoder. That 840 means that whenever the HC Proxy transcodes an application/XML to 841 application/EXI in-band metadata could be lost. 843 3. When content-type is mapped, there is a risk that the content 844 with the destination type would have malware not active in the 845 source type. 847 It is crucial that these risks are well understood and carefully 848 weighed against the actual benefits before deploying the transcoding 849 function. 851 6.5.2. CoRE Link Format 853 The CoRE Link Format [RFC6690] is a set of links (i.e., URIs and 854 their formal relationships) which is carried as content payload in a 855 CoAP response. These links usually include CoAP URIs that might be 856 translated by the HC Proxy to the correspondent HTTP URIs using the 857 implemented URI mapping function (see Section 5). Such a process 858 would inspect the forwarded traffic and attempt to re-write the body 859 of resources with an application/link-format media type, mapping the 860 embedded CoAP URIs to their HTTP counterparts. Some potential issues 861 with this approach are: 863 1. The client may be interested in retrieving original (unaltered) 864 CoAP payloads through the HC Proxy, not modified versions. 866 2. Tampering with payloads is incompatible with resources that are 867 integrity protected (although this is a problem with transcoding 868 in general). 870 3. The HC Proxy needs to fully understand [RFC6690] syntax and 871 semantics, otherwise there is an inherent risk to corrupt the 872 payloads. 874 Therefore, CoRE Link Format payload should only be transcoded at the 875 risk and discretion of the proxy implementer. 877 6.5.3. Diagnostic Messages 879 CoAP responses may, in certain error cases, contain a diagnostic 880 message in the payload explaining the error situation, as described 881 in Section 5.5.2 of [RFC7252]. If present, the CoAP response 882 diagnostic payload SHOULD be copied in the HTTP response body. The 883 CoAP diagnostic message MUST NOT be copied into the HTTP reason- 884 phrase, since it potentially contains CR-LF characters which are 885 incompatible with HTTP reason-phrase syntax. 887 7. Response Code Mapping 889 Table 2 defines the HTTP response status codes to which each CoAP 890 response code SHOULD be mapped. Multiple appearances of a HTTP 891 status code in the second column indicates multiple equivalent HTTP 892 responses are possible based on the same CoAP response code, 893 depending on the conditions cited in the Notes (third column and text 894 below table). 896 +-------------------------------+----------------------------+------+ 897 | CoAP Response Code | HTTP Status Code | Note | 898 +-------------------------------+----------------------------+------+ 899 | 2.01 Created | 201 Created | 1 | 900 | 2.02 Deleted | 200 OK | 2 | 901 | | 204 No Content | 2 | 902 | 2.03 Valid | 304 Not Modified | 3 | 903 | | 200 OK | 4 | 904 | 2.04 Changed | 200 OK | 2 | 905 | | 204 No Content | 2 | 906 | 2.05 Content | 200 OK | | 907 | 2.31 Continue | N/A | 10 | 908 | 4.00 Bad Request | 400 Bad Request | | 909 | 4.01 Unauthorized | 403 Forbidden | 5 | 910 | 4.02 Bad Option | 400 Bad Request | 6 | 911 | 4.02 Bad Option | 500 Internal Server Error | 6 | 912 | 4.03 Forbidden | 403 Forbidden | | 913 | 4.04 Not Found | 404 Not Found | | 914 | 4.05 Method Not Allowed | 400 Bad Request | 7 | 915 | 4.06 Not Acceptable | 406 Not Acceptable | | 916 | 4.08 Request Entity Incomplt. | N/A | 10 | 917 | 4.12 Precondition Failed | 412 Precondition Failed | | 918 | 4.13 Request Ent. Too Large | 413 Payload Too Large | 11 | 919 | 4.15 Unsupported Content-Fmt. | 415 Unsupported Media Type | | 920 | 5.00 Internal Server Error | 500 Internal Server Error | | 921 | 5.01 Not Implemented | 501 Not Implemented | | 922 | 5.02 Bad Gateway | 502 Bad Gateway | | 923 | 5.03 Service Unavailable | 503 Service Unavailable | 8 | 924 | 5.04 Gateway Timeout | 504 Gateway Timeout | | 925 | 5.05 Proxying Not Supported | 502 Bad Gateway | 9 | 926 +-------------------------------+----------------------------+------+ 928 Table 2: CoAP-HTTP Response Code Mappings 930 Notes: 932 1. A CoAP server may return an arbitrary format payload along with 933 this response. If present, this payload MUST be returned as 934 entity in the HTTP 201 response. Section 7.3.2 of [RFC7231] 935 does not put any requirement on the format of the entity. (In 936 the past, [RFC2616] did.) 938 2. The HTTP code is 200 or 204 respectively for the case that a 939 CoAP server returns a payload or not. [RFC7231] Section 5.3 940 requires code 200 in case a representation of the action result 941 is returned for DELETE/POST/PUT, and code 204 if not. Hence, a 942 proxy MUST transfer any CoAP payload contained in a CoAP 2.02 943 response to the HTTP client using a 200 OK response. 945 3. HTTP code 304 (Not Modified) is sent if the HTTP client 946 performed a conditional HTTP request and the CoAP server 947 responded with 2.03 (Valid) to the corresponding CoAP validation 948 request. Note that Section 4.1 of [RFC7232] puts some 949 requirements on header fields that must be present in the HTTP 950 304 response. 952 4. A 200 response to a CoAP 2.03 occurs only when the HC Proxy, for 953 efficiency reasons, is running a local cache. An unconditional 954 HTTP GET which produces a cache-hit, could trigger a re- 955 validation (i.e., a conditional GET) on the CoAP side. The 956 proxy receiving 2.03 updates the freshness of its cached 957 representation and returns it to the HTTP client. 959 5. A HTTP 401 Unauthorized (Section 3.1 of [RFC7235]) response is 960 not applicable because there is no equivalent in CoAP of WWW- 961 Authenticate which is mandatory in a HTTP 401 response. 963 6. If the proxy has a way to determine that the Bad Option is due 964 to the straightforward mapping of a client request header into a 965 CoAP option, then returning HTTP 400 (Bad Request) is 966 appropriate. In all other cases, the proxy MUST return HTTP 500 967 (Internal Server Error) stating its inability to provide a 968 suitable translation to the client's request. 970 7. A CoAP 4.05 (Method Not Allowed) response SHOULD normally be 971 mapped to a HTTP 400 (Bad Request) code, because the HTTP 405 972 response would require specifying the supported methods - which 973 are generally unknown. In this case the HC Proxy SHOULD also 974 return a HTTP reason-phrase in the HTTP status line that starts 975 with the string "CoAP server returned 4.05" in order to 976 facilitate troubleshooting. However, if the HC Proxy has more 977 granular information about the supported methods for the 978 requested resource (e.g., via a Resource Directory 979 ([I-D.ietf-core-resource-directory])) then it MAY send back a 980 HTTP 405 (Method Not Allowed) with a properly filled in "Allow" 981 response-header field (Section 7.4.1 of [RFC7231]). 983 8. The value of the HTTP "Retry-After" response-header field is 984 taken from the value of the CoAP Max-Age Option, if present. 986 9. This CoAP response can only happen if the proxy itself is 987 configured to use a CoAP forward-proxy (Section 5.7 of 988 [RFC7252]) to execute some, or all, of its CoAP requests. 990 10. Only used in CoAP blockwise transfer [RFC7959] between HC Proxy 991 and CoAP server; never translated into a HTTP response. 993 11. Only returned to the HTTP client if the HC Proxy was unable to 994 successfully complete the request by retrying it with CoAP 995 blockwise transfer; see Section 8.3. 997 8. Additional Mapping Guidelines 999 8.1. Caching and Congestion Control 1001 An HC Proxy should cache CoAP responses, and reply whenever 1002 applicable with a cached representation of the requested resource. 1004 If the HTTP client drops the connection after the HTTP request was 1005 made, an HC Proxy should wait for the associated CoAP response and 1006 cache it if possible. Subsequent requests to the HC Proxy for the 1007 same resource can use the result present in cache, or, if a response 1008 has still to come, the HTTP requests will wait on the open CoAP 1009 request. 1011 According to [RFC7252], a proxy must limit the number of outstanding 1012 requests to a given CoAP server to NSTART. To limit the amount of 1013 aggregate traffic to a constrained network, the HC Proxy should also 1014 put a limit on the number of concurrent CoAP requests pending on the 1015 same constrained network; further incoming requests may either be 1016 queued or dropped (returning 503 Service Unavailable). This limit 1017 and the proxy queueing/dropping behavior should be configurable. 1019 Highly volatile resources that are being frequently requested may be 1020 observed [RFC7641] by the HC Proxy to keep their cached 1021 representation fresh while minimizing the amount of CoAP traffic in 1022 the constrained network (see Section 8.2). 1024 8.2. Cache Refresh via Observe 1026 There are cases where using the CoAP observe protocol [RFC7641] to 1027 handle proxy cache refresh is preferable to the validation mechanism 1028 based on ETag as defined in [RFC7252]. Such scenarios include sleepy 1029 CoAP nodes - with possibly high variance in requests' distribution - 1030 which would greatly benefit from a server-driven cache update 1031 mechanism. Ideal candidates for CoAP observe are also crowded or 1032 very low throughput networks, where reduction of the total number of 1033 exchanged messages is an important requirement. 1035 This subsection aims at providing a practical evaluation method to 1036 decide whether refreshing a cached resource R is more efficiently 1037 handled via ETag validation or by establishing an observation on R. 1038 The idea being that the HC Proxy proactively installs an observation 1039 on a "popular enough" resource and actively monitors: 1041 a. Its update pattern on the CoAP side; and 1043 b. The request pattern on the HTTP side; 1045 and uses the formula below to determine whether the observation 1046 should be kept alive or shut down. 1048 Let T_R be the mean time between two client requests to resource R, 1049 let T_C be the mean time between two representation changes of R, and 1050 let M_R be the mean number of CoAP messages per second exchanged to 1051 and from resource R. If we assume that the initial cost for 1052 establishing the observation is negligible, an observation on R 1053 reduces M_R if and only if T_R < 2*T_C with respect to using ETag 1054 validation, that is if and only if the mean arrival rate of requests 1055 for resource R is greater than half the change rate of R. 1057 When observing the resource R, M_R is always upper bounded by 2/T_C. 1059 8.3. Use of CoAP Blockwise Transfer 1061 An HC Proxy SHOULD support CoAP blockwise transfers [RFC7959] to 1062 allow transport of large CoAP payloads while avoiding excessive link- 1063 layer fragmentation in constrained networks, and to cope with small 1064 datagram buffers in CoAP endpoints as described in [RFC7252] 1065 Section 4.6. 1067 An HC Proxy SHOULD attempt to retry a payload-carrying CoAP PUT or 1068 POST request with blockwise transfer if the destination CoAP server 1069 responded with 4.13 (Request Entity Too Large) to the original 1070 request. An HC Proxy SHOULD attempt to use blockwise transfer when 1071 sending a CoAP PUT or POST request message that is larger than 1072 BLOCKWISE_THRESHOLD bytes. The value of BLOCKWISE_THRESHOLD is 1073 implementation-specific; for example, it can be: 1075 o Calculated based on a known or typical UDP datagram buffer size 1076 for CoAP endpoints, or 1078 o Set to N times the known size of a link-layer frame in a 1079 constrained network where e.g., N=5, or 1081 o Preset to a known IP MTU value, or 1083 o Set to a known Path MTU value. 1085 The value BLOCKWISE_THRESHOLD, or the parameters from which it is 1086 calculated, should be configurable in a proxy implementation. The 1087 maximum block size the proxy will attempt to use in CoAP requests 1088 should also be configurable. 1090 The HC Proxy SHOULD detect CoAP endpoints not supporting blockwise 1091 transfers. This can be done by checking for a 4.02 (Bad Option) 1092 response returned by an endpoint in response to a CoAP request with a 1093 Block* Option, and subsequent absence of the 4.02 in response to the 1094 same request without Block* Options. This allows the HC Proxy to be 1095 more efficient, not attempting repeated blockwise transfers to CoAP 1096 servers that do not support it. 1098 8.4. CoAP Multicast 1100 An HC Proxy MAY support CoAP multicast. If it does, the HC Proxy 1101 sends out a multicast CoAP request if the Target CoAP URI's authority 1102 is a multicast IP literal or resolves to a multicast IP address. If 1103 the HC Proxy does not support CoAP multicast, it SHOULD respond 403 1104 (Forbidden) to any valid HTTP request that maps to a CoAP multicast 1105 request. 1107 Details related to supporting CoAP multicast are currently out of 1108 scope of this document since in a proxy scenario an HTTP client 1109 typically expects to receive a single response, not multiple. 1110 However, an HC Proxy that implements CoAP multicast may include 1111 application-specific functions to aggregate multiple CoAP responses 1112 into a single HTTP response. We suggest using the "application/http" 1113 internet media type (Section 8.3.2 of [RFC7230]) to enclose a set of 1114 one or more HTTP response messages, each representing the mapping of 1115 one CoAP response. 1117 For further considerations related to the handling of multicast 1118 requests, see Section 10.1. 1120 8.5. Timeouts 1122 If the CoAP server takes a long time in responding, the HTTP client 1123 or any other proxy in between may timeout. Further discussion of 1124 timeouts in HTTP is available in Section 6.2.4 of [RFC7230]. 1126 An HC Proxy MUST define an internal timeout for each pending CoAP 1127 request, because the CoAP server may silently die before completing 1128 the request. Assuming the Proxy uses confirmable CoAP requests, such 1129 timeout value T SHOULD be at least 1131 T = MAX_RTT + MAX_SERVER_RESPONSE_DELAY 1133 where MAX_RTT is defined in [RFC7252] and MAX_SERVER_RESPONSE_DELAY 1134 is defined in [RFC7390]. 1136 9. IANA Considerations 1138 9.1. New 'core.hc' Resource Type 1140 This document registers a new Resource Type (rt=) Link Target 1141 Attribute, 'core.hc', in the "Resource Type (rt=) Link Target 1142 Attribute Values" subregistry under the "Constrained RESTful 1143 Environments (CoRE) Parameters" registry. 1145 Attribute Value: core.hc 1147 Description: HTTP to CoAP mapping base resource. 1149 Reference: See Section 5.5. 1151 9.2. New 'coap-payload' Internet Media Type 1153 This document defines the "application/coap-payload" media type with 1154 a single parameter "cf". This media type represents any payload that 1155 a CoAP message can carry, having a content format that can be 1156 identified by an integer in range 0-65535 corresponding to a CoAP 1157 Content-Format parameter ([RFC7252], Section 12.3). The parameter 1158 "cf" is the integer defining the CoAP content format. 1160 Type name: application 1162 Subtype name: coap-payload 1164 Required parameters: cf (CoAP Content-Format integer in range 0-65535 1165 denoting the content format of the CoAP payload carried, as defined 1166 by the "CoAP Content-Formats" subregistry that is part of the 1167 "Constrained RESTful Environments (CoRE) Parameters" registry.) 1168 Optional parameters: None 1170 Encoding considerations: Common use is BINARY. The specific CoAP 1171 content format encoding considerations for the selected Content- 1172 Format (cf parameter) apply. The encoding can vary based on the 1173 value of the cf parameter. 1175 Security considerations: The specific CoAP content format security 1176 considerations for the selected Content-Format (cf parameter) apply. 1178 Interoperability considerations: This media type can never be used 1179 directly in CoAP messages because there are no means available to 1180 encode the mandatory 'cf' parameter in CoAP. 1182 Published specification: (this I-D - TBD) 1184 Applications that use this media type: HTTP-to-CoAP Proxies. 1186 Fragment identifier considerations: CoAP does not support URI 1187 fragments; therefore a CoAP payload fragment cannot be identified. 1188 Fragments are not applicable for this media type. 1190 Additional information: 1192 Deprecated alias names for this type: N/A 1194 Magic number(s): N/A 1196 File extension(s): N/A 1198 Macintosh file type code(s): N/A 1200 Person and email address to contact for further information: 1202 Esko Dijk ("esko@ieee.org") 1204 Intended usage: COMMON 1206 Restrictions on usage: 1208 An application (or user) can only use this media type if it has to 1209 represent a CoAP payload of which the specified CoAP Content-Format 1210 is an unrecognized number; such that a proper translation directly to 1211 the equivalent HTTP media type is not possible. 1213 Author: CoRE WG 1215 Change controller: IETF 1216 Provisional registration: No 1218 10. Security Considerations 1220 The security considerations in Section 9.2 of [RFC7230] apply in full 1221 to the HC Proxy. This section discusses security aspects and 1222 requirements that are specific to the deployment and operation of an 1223 HC Proxy. 1225 An HC Proxy located at the boundary of a constrained network is an 1226 easy single point of failure for reducing availability. As such, 1227 special care should be taken in designing, developing and operating 1228 it, keeping in mind that, in most cases, it has fewer limitations 1229 than the constrained devices it is serving. In particular, its 1230 quality of implementation and operation - i.e., use of current 1231 software development practices, careful selection of third party 1232 libraries, sane configuration defaults, an expedited way to upgrade a 1233 running instance - are all essential attributes of the HC Proxy. 1235 The correctness of request parsing in general (including any content 1236 transcoding), and of URI translation in particular, is essential to 1237 the security of the HC Proxy function. This is especially true when 1238 the internal network hosts devices with genuinely limited 1239 capabilities. For this purpose, see also Sections 9.3, 9.4, 9.5 and 1240 9.6 of [RFC7230] for well-known issues related to HTTP request 1241 parsing and Section 11.1 of [RFC7252] for an overview of CoAP 1242 specific concerns related to URI processing - in particular, the 1243 potential impact on access control mechanisms that are based on URIs. 1245 An HC Proxy MUST implement TLS with PSK [RFC4279] and SHOULD 1246 implement TLS [RFC5246] with support for client authentication using 1247 X.509 certificates. A prerequisite of the latter is the availability 1248 of a Certification Authority (CA) to issue suitable certificates. 1249 Although this can be a challenging requirement in certain application 1250 scenarios, it is worth noting that there exist open-source tools 1251 (e.g., [OpenSSL]) that can be used to set up and operate an 1252 application-specific CA. 1254 By default, the HC Proxy MUST authenticate all incoming requests 1255 prior to forwarding them to the CoAP server. This default behavior 1256 MAY be explicitly disabled by an administrator. 1258 The following subparagraphs categorize and discuss a set of specific 1259 security issues related to the translation, caching and forwarding 1260 functionality exposed by an HC Proxy. 1262 10.1. Multicast 1264 Multicast requests impose a non-trivial cost on the constrained 1265 network and endpoints and might be exploited as a DoS attack vector 1266 (see also Section 10.2). From a privacy perspective, they can be 1267 used to gather detailed information about the resources hosted in the 1268 constrained network. For example, an outsider that is able to 1269 successfully query the /.well-known/core could obtain a comprehensive 1270 list of the target's home appliances and devices. From a security 1271 perspective, they can be used to carry out a network reconnaissance 1272 attack to gather information about possible vulnerabilities that 1273 could be exploited at a later point in time. For these reasons, it 1274 is RECOMMENDED that requests to multicast resources are access 1275 controlled with a default-deny policy. It is RECOMMENDED that the 1276 requestor of a multicast resource be strongly authenticated. If 1277 privacy and / or security are first class requirements, for example 1278 whenever the HTTP request transits through the public Internet, the 1279 request SHOULD be transported over a mutually authenticated and 1280 encrypted TLS connection. 1282 10.2. Traffic Overflow 1284 Due to the typically constrained nature of CoAP nodes, particular 1285 attention should be given to the implementation of traffic reduction 1286 mechanisms (see Section 8.1), because an inefficient proxy 1287 implementations can be targeted by unconstrained Internet attackers. 1288 Bandwidth or complexity involved in such attacks is very low. 1290 An amplification attack to the constrained network may be triggered 1291 by a multicast request generated by a single HTTP request which is 1292 mapped to a CoAP multicast resource, as discussed in Section 11.3 of 1293 [RFC7252]. 1295 The risk likelihood of this amplification technique is higher than an 1296 amplification attack carried out by a malicious constrained device 1297 (e.g., ICMPv6 flooding, like Packet Too Big, or Parameter Problem on 1298 a multicast destination [RFC4732]) since it does not require direct 1299 access to the constrained network. 1301 The feasibility of this attack, which disrupts availability of the 1302 targeted CoAP server, can be limited by access controlling the 1303 exposed multicast resources, so that only known/authorized users can 1304 access such URIs. 1306 10.3. Handling Secured Exchanges 1308 An HTTP request can be sent to the HC Proxy over a secured 1309 connection. However, there may not always exist a secure connection 1310 mapping to CoAP. For example, a secure distribution method for 1311 multicast traffic is complex and may not be implemented (see 1312 [RFC7390]). 1314 An HC Proxy should implement rules for security context translations. 1315 For example, all 'https' unicast requests are translated to 'coaps' 1316 requests, or 'https' requests are translated to unsecured 'coap' 1317 requests. Another rule could specify the security policy and 1318 parameters used for DTLS sessions [RFC7925]. Such rules will largely 1319 depend on the application and network context in which the HC Proxy 1320 operates. These rules should be configurable. 1322 It is RECOMMENDED that, by default, accessing a 'coaps' URI is only 1323 allowed from a corresponding 'https' URI. 1325 By default, an HC Proxy SHOULD reject any secured CoAP client request 1326 (i.e., one with a 'coaps' scheme) if there is no configured security 1327 policy mapping. This recommendation may be relaxed in case the 1328 destination network is believed to be secured by other means. 1329 Assuming that CoAP nodes are isolated behind a firewall as in the HC 1330 Proxy deployment shown in Figure 1, the HC Proxy may be configured to 1331 translate the incoming HTTPS request using plain CoAP (NoSec mode). 1333 10.4. URI Mapping 1335 The following risks related to the URI mapping described in Section 5 1336 and its use by HC Proxy have been identified: 1338 DoS attack on the constrained/CoAP network. 1339 Mitigation: by default deny any Target CoAP URI whose authority is 1340 (or maps to) a multicast address. Then explicitly white-list 1341 multicast resources/authorities that are allowed to be de- 1342 referenced. See also Section 8.4. 1344 Leaking information on the constrained/CoAP network resources and 1345 topology. 1346 Mitigation: by default deny any Target CoAP URI (especially 1347 /.well-known/core is a resource to be protected), and then 1348 explicitly white-list resources that are allowed to be seen from 1349 outside. 1351 The internal CoAP Target resource is totally transparent from 1352 outside. 1354 Mitigation: implement an HTTPS-only interface, which makes the 1355 Target CoAP URI totally opaque to a passive attacker. 1357 11. Acknowledgments 1359 An initial version of Table 2 in Section 7 has been provided in 1360 revision -05 of the CoRE CoAP I-D. Special thanks to Peter van der 1361 Stok for countless comments and discussions on this document that 1362 contributed to its current structure and text. 1364 Thanks to Abhijan Bhattacharyya, Alexey Melnikov, Brian Frank, 1365 Carsten Bormann, Christian Amsuess, Christian Groves, Cullen 1366 Jennings, Dorothy Gellert, Francesco Corazza, Francis Dupont, Hannes 1367 Tschofenig, Jaime Jimenez, Kathleen Moriarty, Kepeng Li, Kerry Lynn, 1368 Klaus Hartke, Larry Masinter, Linyi Tian, Michele Rossi, Michele 1369 Zorzi, Nicola Bui, Peter Saint-Andre, Sean Leonard, Spencer Dawkins, 1370 Stephen Farrell, Suresh Krishnan, Zach Shelby for helpful comments 1371 and discussions that have shaped the document. 1373 The research leading to these results has received funding from the 1374 European Community's Seventh Framework Programme [FP7/2007-2013] 1375 under grant agreement n.251557. 1377 12. References 1379 12.1. Normative References 1381 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1382 Requirement Levels", BCP 14, RFC 2119, 1383 DOI 10.17487/RFC2119, March 1997, 1384 . 1386 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1387 Resource Identifier (URI): Generic Syntax", STD 66, 1388 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1389 . 1391 [RFC4279] Eronen, P., Ed. and H. Tschofenig, Ed., "Pre-Shared Key 1392 Ciphersuites for Transport Layer Security (TLS)", 1393 RFC 4279, DOI 10.17487/RFC4279, December 2005, 1394 . 1396 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 1397 Specifications: ABNF", STD 68, RFC 5234, 1398 DOI 10.17487/RFC5234, January 2008, 1399 . 1401 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1402 (TLS) Protocol Version 1.2", RFC 5246, 1403 DOI 10.17487/RFC5246, August 2008, 1404 . 1406 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 1407 and D. Orchard, "URI Template", RFC 6570, 1408 DOI 10.17487/RFC6570, March 2012, 1409 . 1411 [RFC6690] Shelby, Z., "Constrained RESTful Environments (CoRE) Link 1412 Format", RFC 6690, DOI 10.17487/RFC6690, August 2012, 1413 . 1415 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1416 Protocol (HTTP/1.1): Message Syntax and Routing", 1417 RFC 7230, DOI 10.17487/RFC7230, June 2014, 1418 . 1420 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1421 Protocol (HTTP/1.1): Semantics and Content", RFC 7231, 1422 DOI 10.17487/RFC7231, June 2014, 1423 . 1425 [RFC7232] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1426 Protocol (HTTP/1.1): Conditional Requests", RFC 7232, 1427 DOI 10.17487/RFC7232, June 2014, 1428 . 1430 [RFC7235] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1431 Protocol (HTTP/1.1): Authentication", RFC 7235, 1432 DOI 10.17487/RFC7235, June 2014, 1433 . 1435 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 1436 Application Protocol (CoAP)", RFC 7252, 1437 DOI 10.17487/RFC7252, June 2014, 1438 . 1440 [RFC7641] Hartke, K., "Observing Resources in the Constrained 1441 Application Protocol (CoAP)", RFC 7641, 1442 DOI 10.17487/RFC7641, September 2015, 1443 . 1445 [RFC7959] Bormann, C. and Z. Shelby, Ed., "Block-Wise Transfers in 1446 the Constrained Application Protocol (CoAP)", RFC 7959, 1447 DOI 10.17487/RFC7959, August 2016, 1448 . 1450 12.2. Informative References 1452 [Fielding] 1453 Fielding, R., "Architectural Styles and the Design of 1454 Network-based Software Architectures", PhD 1455 Dissertation, University of California, Irvine, 1456 ISBN 0-599-87118-0, 2000. 1458 [I-D.ietf-core-links-json] 1459 Li, K., Rahman, A., and C. Bormann, "Representing CoRE 1460 Formats in JSON and CBOR", draft-ietf-core-links-json-06 1461 (work in progress), July 2016. 1463 [I-D.ietf-core-resource-directory] 1464 Shelby, Z., Koster, M., Bormann, C., and P. Stok, "CoRE 1465 Resource Directory", draft-ietf-core-resource-directory-09 1466 (work in progress), October 2016. 1468 [OpenSSL] The OpenSSL Project, , "ca - sample minimal CA 1469 application", 1998-2016, 1470 . 1472 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 1473 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 1474 Transfer Protocol -- HTTP/1.1", RFC 2616, 1475 DOI 10.17487/RFC2616, June 1999, 1476 . 1478 [RFC3040] Cooper, I., Melve, I., and G. Tomlinson, "Internet Web 1479 Replication and Caching Taxonomy", RFC 3040, 1480 DOI 10.17487/RFC3040, January 2001, 1481 . 1483 [RFC4732] Handley, M., Ed., Rescorla, E., Ed., and IAB, "Internet 1484 Denial-of-Service Considerations", RFC 4732, 1485 DOI 10.17487/RFC4732, December 2006, 1486 . 1488 [RFC6454] Barth, A., "The Web Origin Concept", RFC 6454, 1489 DOI 10.17487/RFC6454, December 2011, 1490 . 1492 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 1493 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 1494 October 2013, . 1496 [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for 1497 Constrained-Node Networks", RFC 7228, 1498 DOI 10.17487/RFC7228, May 2014, 1499 . 1501 [RFC7390] Rahman, A., Ed. and E. Dijk, Ed., "Group Communication for 1502 the Constrained Application Protocol (CoAP)", RFC 7390, 1503 DOI 10.17487/RFC7390, October 2014, 1504 . 1506 [RFC7925] Tschofenig, H., Ed. and T. Fossati, "Transport Layer 1507 Security (TLS) / Datagram Transport Layer Security (DTLS) 1508 Profiles for the Internet of Things", RFC 7925, 1509 DOI 10.17487/RFC7925, July 2016, 1510 . 1512 [W3C.REC-html5-20141028] 1513 Hickson, I., Berjon, R., Faulkner, S., Leithead, T., 1514 Navara, E., O'Connor, E., and S. Pfeiffer, "HTML5", W3C 1515 Recommendation REC-html5-20141028, 2014, 1516 . 1518 Appendix A. Media Type Mapping Source Code 1520 #!/usr/bin/env python 1522 import unittest 1523 import re 1525 class CoAPContentFormatRegistry(object): 1526 """Map an Internet media type (and optional inherent encoding) to a 1527 CoAP content format. 1528 """ 1529 TEXT_PLAIN = 0 1530 LINK_FORMAT = 40 1531 XML = 41 1532 OCTET_STREAM = 42 1533 EXI = 47 1534 JSON = 50 1535 CBOR = 60 1536 GROUP_JSON = 256 1538 # http://www.iana.org/assignments/core-parameters/core-parameters.xhtml 1539 # as of 2016/10/24. 1540 LOOKUP_TABLE = { 1541 ("text/plain;charset=utf-8", None): TEXT_PLAIN, 1542 ("application/link-format", None): LINK_FORMAT, 1543 ("application/xml", None): XML, 1544 ("application/octet-stream", None): OCTET_STREAM, 1545 ("application/exi", None): EXI, 1546 ("application/json", None): JSON, 1547 ("application/cbor", None): CBOR, 1548 ("application/coap-group+json", "utf-8"): GROUP_JSON, 1549 } 1551 def lookup(self, media_type, encoding): 1552 """Return the CoAP Content Format matching the supplied 1553 media type (and optional encoding), or None if no 1554 match can be found.""" 1555 return CoAPContentFormatRegistry.LOOKUP_TABLE.get( 1556 (media_type, encoding), None) 1558 class LooseMediaTypeMapper(object): 1559 # Order matters in this table: more specific types have higher rank 1560 # compared to less specific types. 1561 # This code only performs a shallow validation of acceptable 1562 # characters, and assumes overall validation of media type and 1563 # subtype has been done beforehand. 1564 LOOKUP_TABLE = [ 1565 (re.compile("application/.+\+xml$"), "application/xml"), 1566 (re.compile("application/.+\+json$"), "application/json"), 1567 (re.compile("application/.+\+cbor$"), "application/cbor"), 1568 (re.compile("text/xml$"), "application/xml"), 1569 (re.compile("text/[a-z\.\-\+]+$"), "text/plain;charset=utf-8"), 1570 (re.compile("[a-z]+/[a-z\.\-\+]+$"), "application/octet-stream") 1571 ] 1573 def lookup(self, media_type): 1574 """Return the best loose media type match available using 1575 the contents of LOOKUP_TABLE.""" 1576 for entry in LooseMediaTypeMapper.LOOKUP_TABLE: 1577 if entry[0].match(media_type) is not None: 1578 return entry[1] 1579 return None 1581 def mt2cf(media_type, encoding=None, 1582 coap_cf_registry=CoAPContentFormatRegistry(), 1583 loose_mapper=None): 1584 """Return a CoAP Content-Format given an Internet Media Type and 1585 its optional encoding. The current (as of 2016/10/24) CoAP 1586 Content Format Registry is supplied by default. An optional 1587 'loose-mapping' implementation can be supplied by the caller.""" 1589 assert media_type is not None 1590 assert coap_cf_registry is not None 1592 # Lookup the CoAP Content-Formats registry 1593 content_format = coap_cf_registry.lookup(media_type, encoding) 1595 # If an exact match is not found and a loose mapper has been 1596 # supplied, try to use it to get a media type with which to 1597 # re-try the CoAP Content-Formats registry lookup. 1598 if content_format is None and loose_mapper is not None: 1599 content_format = coap_cf_registry.lookup( 1600 loose_mapper.lookup(media_type), encoding) 1602 return content_format 1604 class TestMT2CF(unittest.TestCase): 1606 def testMissingContentType(self): 1607 with self.assertRaises(AssertionError): 1608 mt2cf(None) 1610 def testMissingContentFormatRegistry(self): 1611 with self.assertRaises(AssertionError): 1612 mt2cf(None, coap_cf_registry=None) 1614 def testTextPlain(self): 1615 self.assertEqual(mt2cf("text/plain;charset=utf-8"), 1616 CoAPContentFormatRegistry.TEXT_PLAIN) 1618 def testLinkFormat(self): 1619 self.assertEqual(mt2cf("application/link-format"), 1620 CoAPContentFormatRegistry.LINK_FORMAT) 1622 def testXML(self): 1623 self.assertEqual(mt2cf("application/xml"), 1624 CoAPContentFormatRegistry.XML) 1626 def testOctetStream(self): 1627 self.assertEqual(mt2cf("application/octet-stream"), 1628 CoAPContentFormatRegistry.OCTET_STREAM) 1630 def testEXI(self): 1631 self.assertEqual(mt2cf("application/exi"), 1632 CoAPContentFormatRegistry.EXI) 1634 def testJSON(self): 1635 self.assertEqual(mt2cf("application/json"), 1636 CoAPContentFormatRegistry.JSON) 1638 def testCBOR(self): 1639 self.assertEqual(mt2cf("application/cbor"), 1640 CoAPContentFormatRegistry.CBOR) 1642 def testCoAPGroupJSON(self): 1643 self.assertEqual(mt2cf("application/coap-group+json", 1644 "utf-8"), 1645 CoAPContentFormatRegistry.GROUP_JSON) 1647 def testUnknownMediaType(self): 1648 self.assertFalse(mt2cf("unknown/media-type")) 1650 def testLooseXML1(self): 1651 self.assertEqual( 1652 mt2cf( 1653 "application/somesubtype+xml", 1654 loose_mapper=LooseMediaTypeMapper()), 1655 CoAPContentFormatRegistry.XML) 1657 def testLooseXML2(self): 1658 self.assertEqual( 1659 mt2cf( 1660 "text/xml", 1661 loose_mapper=LooseMediaTypeMapper()), 1662 CoAPContentFormatRegistry.XML) 1664 def testLooseJSON(self): 1665 self.assertEqual( 1666 mt2cf( 1667 "application/somesubtype+json", 1668 loose_mapper=LooseMediaTypeMapper()), 1669 CoAPContentFormatRegistry.JSON) 1671 def testLooseCBOR(self): 1672 self.assertEqual( 1673 mt2cf( 1674 "application/somesubtype+cbor", 1675 loose_mapper=LooseMediaTypeMapper()), 1676 CoAPContentFormatRegistry.CBOR) 1678 def testLooseText(self): 1679 self.assertEqual( 1680 mt2cf( 1681 "text/somesubtype", 1682 loose_mapper=LooseMediaTypeMapper()), 1683 CoAPContentFormatRegistry.TEXT_PLAIN) 1685 def testLooseUnknown(self): 1686 self.assertEqual( 1687 mt2cf( 1688 "application/somesubtype-of-some-sort+format", 1689 loose_mapper=LooseMediaTypeMapper()), 1690 CoAPContentFormatRegistry.OCTET_STREAM) 1692 def testLooseInvalidStartsWithNonAlpha(self): 1693 self.assertFalse( 1694 mt2cf( 1695 " application/somesubtype", 1696 loose_mapper=LooseMediaTypeMapper())) 1698 def testLooseInvalidEndsWithUnexpectedChar(self): 1699 self.assertFalse( 1700 mt2cf( 1701 "application/somesubtype ", 1702 loose_mapper=LooseMediaTypeMapper())) 1704 def testLooseInvalidUnexpectedCharInTheMiddle(self): 1705 self.assertFalse( 1706 mt2cf( 1707 "application /somesubtype", 1708 loose_mapper=LooseMediaTypeMapper())) 1710 def testLooseInvalidNoSubType1(self): 1711 self.assertFalse( 1712 mt2cf( 1713 "application", 1714 loose_mapper=LooseMediaTypeMapper())) 1716 def testLooseInvalidNoSubType2(self): 1717 self.assertFalse( 1718 mt2cf( 1719 "application/", 1720 loose_mapper=LooseMediaTypeMapper())) 1722 if __name__ == "__main__": 1723 unittest.main(verbosity=2) 1725 Appendix B. Change Log 1727 [Note to RFC Editor: Please remove this section before publication.] 1729 Changes from ietf-16 to ietf-17: 1731 o Intended status from Informational to Standards Track; 1732 o Stephen Farrell's DISCUSS 1734 o Added 2.31 and 4.08 CoAP response codes to the Response Code 1735 Mapping table. 1737 o Editorial fixes 1739 Changes from ietf-15 to ietf-16 (Apps-Dir review): 1741 o Larry Masinter's comments. 1743 Changes from ietf-14 to ietf-15 (IESG review): 1745 o Kathleen Moriarty's DISCUSS and COMMENT; 1747 o Stephen Farrell's COMMENT; 1749 o Suresh Krishnan DISCUSS; 1751 o Spencer Dawkins' DISCUSS and COMMENT; 1753 Changes from ietf-13 to ietf-14: 1755 o Addressed Gen-ART and AD review comments. 1757 Changes from ietf-12 to ietf-13 (Christian Amsuess' comments): 1759 o More missing slashes in URI mapping template examples. 1761 Changes from ietf-11 to ietf-12 (2nd WGLC): 1763 o Addressed a few editorial issues (including a clarification on 1764 when to use qq vs q in the URI mapping template). 1766 o Fixed missing slash in one template example. 1768 o Added para about the need for future CoAP protocol elements to 1769 define their own HTTP mappings. 1771 Changes from ietf-10 to ietf-11 (Chair review): 1773 o Removed cu/su distinction from the URI mapping template. 1775 o Addressed a few editorial issues. 1777 Changes from ietf-09 to ietf-10: 1779 o Addressed Ticket #401 - Clarified that draft covers not only 1780 Reverse HC Proxy but that many parts also apply to Forward and 1781 Interception Proxies. 1783 o Clarified that draft concentrates on the HTTP-to-CoAP mapping 1784 direction (i.e., the HC Proxy is an HTTP server and a CoAP 1785 client). 1787 o Clarified the "null mapping" case where no CoAP URI information is 1788 embedded in the HTTP request URI. 1790 o Moved multicast related security text to the "Security 1791 Considerations" to consolidate all security information in one 1792 location. 1794 o Removed references to "placement" of proxy (e.g., server-side vs 1795 client-side) as is confusing and provides little added value. 1797 o Fixed version numbers on references that were corrupted in last 1798 revision due to outdated xml2rfc conversion tool local cache. 1800 o Various editorial improvements. 1802 Changes from ietf-08 to ietf-09: 1804 o Clean up requirements language as per Klaus' comment. 1806 Changes from ietf-07 to ietf-08: 1808 o Addressed WGLC review comments from Klaus Hartke as per the 1809 correspondence of March 9, 2016 on the CORE WG mailing list. 1811 Changes from ietf-06 to ietf-07: 1813 o Addressed Ticket #384 - Section 5.4.1 describes briefly 1814 (informative) how to discover CoAP resources from an HTTP client. 1816 o Addressed Ticket #378 - For HTTP media type to CoAP content format 1817 mapping and vice versa: a new draft (TBD) may be proposed in CoRE 1818 which describes an approach for automatic updating of the media 1819 type mapping. This was noted in Section 6.1 but is otherwise 1820 outside the scope of this draft. 1822 o Addressed Ticket #377 - Added IANA section that defines a new HTTP 1823 media type "application/coap-payload" and created new Section 6.2 1824 on how to use it. 1826 o Addressed Ticket #376 - Updated Table 2 (and corresponding note 7) 1827 to indicate that a CoAP 4.05 (Method Not Allowed) Response Code 1828 should be mapped to an HTTP 400 (Bad Request). 1830 o Added note to comply to ABNF when translating CoAP diagnostic 1831 payload to reason-phrase in Section 6.5.3. 1833 Changes from ietf-05 to ietf-06: 1835 o Fully restructured the draft, bringing introductory text more to 1836 the front and allocating main sections to each of the key topics; 1837 addressing Ticket #379; 1839 o Addressed Ticket #382, fix of enhanced form URI template 1840 definition of q in Section 5.3.2; 1842 o Addressed Ticket #381, found a mapping 4.01 to 401 Unauthorized in 1843 Section 7; 1845 o Addressed Ticket #380 (Add IANA registration for "core.hc" 1846 Resource Type) in Section 9; 1848 o Addressed Ticket #376 (CoAP 4.05 response can't be translated to 1849 HTTP 405 by HC Proxy) in Section 7 by use of empty 'Allow' header; 1851 o Removed details on the pros and cons of HC Proxy placement 1852 options; 1854 o Addressed review comments of Carsten Bormann; 1856 o Clarified failure in mapping of HTTP Accept headers (Section 6.3); 1858 o Clarified detection of CoAP servers not supporting blockwise 1859 (Section 8.3); 1861 o Changed CoAP request timeout min value to MAX_RTT + 1862 MAX_SERVER_RESPONSE_DELAY (Section 8.6); 1864 o Added security section item (Section 10.3) related to use of CoAP 1865 blockwise transfers; 1867 o Many editorial improvements. 1869 Changes from ietf-04 to ietf-05: 1871 o Addressed Ticket #366 (Mapping of CoRE Link Format payloads to be 1872 valid in HTTP Domain?) in Section 6.3.3.2 (Content Transcoding - 1873 CORE Link Format); 1875 o Addressed Ticket #375 (Add requirement on mapping of CoAP 1876 diagnostic payload) in Section 6.3.3.3 (Content Transcoding - 1877 Diagnostic Messages); 1879 o Addressed comment from Yusuke (http://www.ietf.org/mail- 1880 archive/web/core/current/msg05491.html) in Section 6.3.3.1 1881 (Content Transcoding - General); 1883 o Various editorial improvements. 1885 Changes from ietf-03 to ietf-04: 1887 o Expanded use case descriptions in Section 4; 1889 o Fixed/enhanced discovery examples in Section 5.4.1; 1891 o Addressed Ticket #365 (Add text on media type conversion by HTTP- 1892 CoAP proxy) in new Section 6.3.1 (Generalized media type mapping) 1893 and new Section 6.3.2 (Content translation); 1895 o Updated HTTPBis WG draft references to recently published RFC 1896 numbers. 1898 o Various editorial improvements. 1900 Changes from ietf-02 to ietf-03: 1902 o Closed Ticket #351 "Add security implications of proposed default 1903 HTTP-CoAP URI mapping"; 1905 o Closed Ticket #363 "Remove CoAP scheme in default HTTP-CoAP URI 1906 mapping"; 1908 o Closed Ticket #364 "Add discovery of HTTP-CoAP mapping 1909 resource(s)". 1911 Changes from ietf-01 to ietf-02: 1913 o Selection of single default URI mapping proposal as proposed to WG 1914 mailing list 2013-10-09. 1916 Changes from ietf-00 to ietf-01: 1918 o Added URI mapping proposals to Section 4 as per the Email 1919 proposals to WG mailing list from Esko. 1921 Authors' Addresses 1923 Angelo P. Castellani 1924 University of Padova 1925 Via Gradenigo 6/B 1926 Padova 35131 1927 Italy 1929 Email: angelo@castellani.net 1931 Salvatore Loreto 1932 Ericsson 1933 Hirsalantie 11 1934 Jorvas 02420 1935 Finland 1937 Email: salvatore.loreto@ericsson.com 1939 Akbar Rahman 1940 InterDigital Communications, LLC 1941 1000 Sherbrooke Street West 1942 Montreal H3A 3G4 1943 Canada 1945 Phone: +1 514 585 0761 1946 Email: Akbar.Rahman@InterDigital.com 1948 Thomas Fossati 1949 Nokia 1950 3 Ely Road 1951 Milton, Cambridge CB24 6DD 1952 UK 1954 Email: thomas.fossati@nokia.com 1956 Esko Dijk 1957 Philips Lighting 1958 High Tech Campus 7 1959 Eindhoven 5656 AE 1960 The Netherlands 1962 Email: esko.dijk@philips.com