No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0332.xml 103KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>HTTP over XMPP transport</title>
  10. <abstract>This specification defines how XMPP can be used to transport HTTP communication over peer-to-peer networks.</abstract>
  11. &LEGALNOTICE;
  12. <number>0332</number>
  13. <status>Deferred</status>
  14. <lastcall>2014-10-21</lastcall>
  15. <type>Standards Track</type>
  16. <sig>Standards</sig>
  17. <approver>Council</approver>
  18. <dependencies>
  19. <spec>XMPP Core</spec>
  20. <spec>XEP-0001</spec>
  21. <spec>XEP-0030</spec>
  22. <spec>XEP-0047</spec>
  23. <spec>XEP-0131</spec>
  24. <spec>XEP-0137</spec>
  25. <spec>XEP-0166</spec>
  26. </dependencies>
  27. <supersedes/>
  28. <supersededby/>
  29. <shortname>NOT_YET_ASSIGNED</shortname>
  30. &peterwaher;
  31. <revision>
  32. <version>0.5</version>
  33. <date>2017-09-11</date>
  34. <initials>XEP Editor (jwi)</initials>
  35. <remark>Defer due to lack of activity.</remark>
  36. </revision>
  37. <revision>
  38. <version>0.4</version>
  39. <date>2015-11-09</date>
  40. <initials>pw</initials>
  41. <remark>
  42. <p>Updated contact information.</p>
  43. <p>Updated example JIDs to example.org</p>
  44. </remark>
  45. </revision>
  46. <revision>
  47. <version>0.3</version>
  48. <date>2014-08-12</date>
  49. <initials>pw</initials>
  50. <remark>
  51. <p>A sequence number have been added to chunks, to allow chunked service to work over servers that do not maintain message order.</p>
  52. </remark>
  53. </revision>
  54. <revision>
  55. <version>0.2</version>
  56. <date>2014-07-07</date>
  57. <initials>pw</initials>
  58. <remark>
  59. <p>Updated invalid links.</p>
  60. </remark>
  61. </revision>
  62. <revision>
  63. <version>0.1</version>
  64. <date>2013-07-11</date>
  65. <initials>psa</initials>
  66. <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  67. </revision>
  68. <revision>
  69. <version>0.0.7</version>
  70. <date>2013-07-09</date>
  71. <initials>pw</initials>
  72. <remark>
  73. <p>Added remarks for the xml encoding to clarify the need to avoid creating invalid XMPP.</p>
  74. <p>Clarification added regarding to base64 content size when using schema-aware EXI compression.</p>
  75. <p>The name of the new proposed URI scheme has been changed from xmpp to httpx.</p>
  76. <p>An URI Scheme Registration Template has been added, as per BCP 35.</p>
  77. </remark>
  78. </revision>
  79. <revision>
  80. <version>0.0.6</version>
  81. <date>2013-06-17</date>
  82. <initials>pw</initials>
  83. <remark>
  84. <p>Removed the streamBase64 transfer mechanism and replaced it with In-band bytestreams (IBB).</p>
  85. <p>Created new examples, avoiding re-use of known public examples.</p>
  86. <p>Extended the descriptions of the different transfer mechanisms.</p>
  87. <p>Ability to state capabilities of the client in the request.</p>
  88. </remark>
  89. </revision>
  90. <revision>
  91. <version>0.0.5</version>
  92. <date>2013-05-22</date>
  93. <initials>pw</initials>
  94. <remark>
  95. <p>Changed IQ stanza type from 'get' to 'set' for all HTTP methods.</p>
  96. </remark>
  97. </revision>
  98. <revision>
  99. <version>0.0.4</version>
  100. <date>2013-05-14</date>
  101. <initials>pw</initials>
  102. <remark>
  103. <p>Updated format of encoding table, and made it into a definition list.</p>
  104. <p>Language corrections.</p>
  105. </remark>
  106. </revision>
  107. <revision>
  108. <version>0.0.3</version>
  109. <date>2013-05-10</date>
  110. <initials>pw</initials>
  111. <remark>
  112. <p>Added more information about chunking.</p>
  113. <p>Added implementation notes regarding bandwidth and stanza size limitations in XMPP Servers.</p>
  114. </remark>
  115. </revision>
  116. <revision>
  117. <version>0.0.2</version>
  118. <date>2013-05-08</date>
  119. <initials>pw</initials>
  120. <remark>
  121. <p>Added support for XEP-0131, Stanza Headers and Internet Metadata.</p>
  122. </remark>
  123. </revision>
  124. <revision>
  125. <version>0.0.1</version>
  126. <date>2013-05-05</date>
  127. <initials>pw</initials>
  128. <remark>
  129. <p>First draft.</p>
  130. </remark>
  131. </revision>
  132. </header>
  133. <section1 topic='Introduction' anchor='intro'>
  134. <p>
  135. Many documents have been written on how to transport XMPP datagrams using HTTP. The motivation behind such solutions has often been to be able to use XMPP in
  136. scripting languages such as Java Script running in web browsers.
  137. </p>
  138. <p>
  139. But up to this point very little has been written about the reverse: How to transport HTTP methods and HTTP responses over an XMPP-based peer-to-peer network.
  140. Here, the motivation is as follows: There are multitudes of applications and APIs written that are based on HTTP over TCP as the basic communication transport protocol.
  141. As these are moving closer and closer to the users, problems arise when the users want to protect their data and services using firewalls. Even though there are methods
  142. today to open up firewalls manually or automatically permit communication with such devices and applications, you still open up the application for everybody. This
  143. rises the need for more advanced security measures which is sometimes difficult to implement using HTTP.
  144. </p>
  145. <p>
  146. The XMPP protocol however does not have the same problems as HTTP in these regards. It's a peer-to-peer protocol naturally allowing communication with applications
  147. and devices behind firewalls. It also includes advanced user authentication and authorization which makes it easier to make sure unauthorized access to private
  148. content is prevented.
  149. </p>
  150. <p>
  151. Furthermore, with the advent of semantic web technologies and its use in web 3.0 and Internet of Things applications, such applications move even more rapidly into
  152. the private spheres of the users, where security and privacy is of paramount importance, it is necessary to use more secure transport protocols than HTTP over TCP.
  153. </p>
  154. <p>
  155. There are many different types of HTTP-based communication that one would like to be able to transport over XMPP. A non-exhaustive list can include:
  156. </p>
  157. <ul>
  158. <li>Web Content like pages, images, files, etc.</li>
  159. <li>Web Forms.</li>
  160. <li>Web Services (SOAP, REST, etc.)</li>
  161. <li>Semantic Web Resources (RDF, Turtle, etc.)</li>
  162. <li>Federated SPARQL queries (SQL-type query language for the semantic web, or web 3.0)</li>
  163. <li>Streamed multi-media content in UPnP and DLNA networks.</li>
  164. </ul>
  165. <p>
  166. Instead of trying to figure out all possible things transportable over HTTP and make them transportable over XMPP, this document ignores the type of content transported,
  167. and instead focuses on encoding and decoding the original HTTP requests and responses, building an HTTP tunnel over an existing XMPP connection. It would enable
  168. existing applications to work seamlessly over XMPP if browsers and web services supported this extension (like displaying your home control application on your phone
  169. when you are at work), without the need to update the myriad of existing applications. It would also permit federated SPARQL queries in personal networks with the added
  170. benefit of being able to control who can talk to who (or what can talk to what) through established friendship relationships.
  171. </p>
  172. <p>
  173. Previous extensions handling different aspects of XMPP working together with HTTP:
  174. </p>
  175. <ul>
  176. <li>
  177. &xep0070;: This specification handles client authentication of resources, where there are three parties: HTTP Client &lt;-&gt; HTTP Server/XMPP Client &lt;-&gt; XMPP Server.
  178. Here HTTP Client authentication to resources on the HTTP Server is made by a third party, an XMPP Server.
  179. </li>
  180. <li>
  181. &xep0072;: This specification handles execution of SOAP-based web services specifically. This specification has some benefits regarding to Web Service calls over XMPP,
  182. but is only one example of all types of HTTP-based communication one would desire to transport over XMPP.
  183. </li>
  184. <li>
  185. &xep0124;: This specification handles XMPP-based communication over HTTP sessions (BOSH), allowing for instance, XMPP communication in java script using the
  186. XML HTTP Request object. This is in some way the reverse of what this document proposes to do.
  187. </li>
  188. <li>
  189. &xep0131;: While not directly related to HTTP, it is used to transport headers in the form of collections of key-value pairs, exactly as is done in HTTP. The format
  190. for encoding headers into XMP defined by this XEP will be re-used in this XEP.
  191. </li>
  192. <li>
  193. &xep0147;: This informational specification proposes ways to define XMPP-actions using URL's. The xmpp URI scheme is formally defined in &rfc5122;.
  194. This document will propose a different URI scheme for HTTP-based resources over an XMPP transport: httpx.
  195. </li>
  196. </ul>
  197. </section1>
  198. <section1 topic='Requirements' anchor='reqs'>
  199. <p>
  200. This document presupposes the server already has a web server (HTTP Server) implementation, and that it hosts content through it, content which can be both
  201. dynamic (i.e. generated) or static (e.g. files) in nature. Content, which it wants to
  202. publish to XMPP clients as well as HTTP clients. It also presupposes that the client is aware of HTTP semantics and MIME encoding.
  203. </p>
  204. </section1>
  205. <section1 topic='Glossary' anchor='glossary'>
  206. <p>The following table lists common terms and corresponding descriptions.</p>
  207. <dl>
  208. <di>
  209. <dt>HTTP</dt>
  210. <dd>
  211. Hyper Text Transfer Protocol. Version 1.1 of HTTP is described in RFC 2616 <note>
  212. RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 &lt;<link url='http://tools.ietf.org/html/rfc2616'>http://tools.ietf.org/html/rfc2616</link>&gt;
  213. </note>. The PATCH method is described in RFC 5789 <note>
  214. RFC 5789: PATCH Method for HTTP &lt;<link url='http://tools.ietf.org/html/rfc5789'>http://tools.ietf.org/html/rfc5789</link>&gt;
  215. </note>
  216. </dd>
  217. </di>
  218. <di>
  219. <dt>HTTP Client</dt>
  220. <dd>An HTTP Client is the initiator of an HTTP Request.</dd>
  221. </di>
  222. <di>
  223. <dt>HTTP Method</dt>
  224. <dd>
  225. HTTP Methods are: <strong>OPTIONS</strong>, <strong>GET</strong>, <strong>HEAD</strong>, <strong>POST</strong>,
  226. <strong>PUT</strong>, <strong>DELETE</strong>, <strong>TRACE</strong> and <strong>PATCH</strong>. The HTTP
  227. Method CONNECT is not supported by this specification.
  228. </dd>
  229. </di>
  230. <di>
  231. <dt>HTTP Request</dt>
  232. <dd>An HTTP Request consists of a HTTP Method, version information, headers and optional body.</dd>
  233. </di>
  234. <di>
  235. <dt>HTTP Resource</dt>
  236. <dd>A resource on an HTTP Server identified by a path. Each path begins with a separator character (/).</dd>
  237. </di>
  238. <di>
  239. <dt>HTTP Response</dt>
  240. <dd>An HTTP Response consists of a status code, optional status message, headers and optional body.</dd>
  241. </di>
  242. <di>
  243. <dt>HTTP Server</dt>
  244. <dd>An HTTP Server responds to HTTP Client requests.</dd>
  245. </di>
  246. <di>
  247. <dt>Web Server</dt>
  248. <dd>Used synonymously with HTTP Server.</dd>
  249. </di>
  250. </dl>
  251. </section1>
  252. <section1 topic='Use Cases' anchor='usecases'>
  253. <p>
  254. All HTTP communication is done using the <strong>Request</strong>/<strong>Response</strong> paradigm. Each HTTP Request is made sending an <strong>iq</strong>-stanza
  255. containing a <strong>req</strong> element to the server. Each <strong>iq</strong>-stanza sent is of type <strong>set</strong>.
  256. </p>
  257. <p>
  258. When the server responds, it does so by sending an <strong>iq</strong>-stanza response (type <strong>result</strong>) back to the client containing a <strong>resp</strong>
  259. element. Since responses are asynchronous, and since multiple requests may be active at the same time, responses may be returned in a different order than the in which the
  260. original requests were made.
  261. </p>
  262. <p>
  263. Requests or responses containing data must also consider how this data should be encoded within the XML telegram. Normally in HTTP, content and headers are separated
  264. by a blank line, and the transfer of the content is made in the same stream. Specific HTTP headers are used to define how the content is transferred and encoded within
  265. the stream (Content-Type, Content-Length, Content-Encoding, Content-Transfer-Encoding). This approach is not possible if the response is to be embedded in an XML telegram,
  266. since it can interfere with the encoding of the encompassing XML.
  267. </p>
  268. <p>
  269. To solve this, this document specifies additional data transfer mechanisms that are compatible with the XMPP protocol. The normal HTTP-based content transfer headers will
  270. still be transported, but do not affect the content encoding used in the XMPP transport. The following content encoding methods are available:
  271. </p>
  272. <dl>
  273. <di>
  274. <dt>text</dt>
  275. <dd>
  276. <p>
  277. Normal text content. The text is encoded as text within XML, using the same encoding used by the XML stream. XML escape characters (&lt;, &gt; and &amp;)
  278. are escaped using the normal &amp;lt;, &amp;gt; and &amp;amp; character escape sequences.
  279. </p>
  280. </dd>
  281. </di>
  282. <di>
  283. <dt>xml</dt>
  284. <dd>
  285. <p>
  286. Xml content embedded in the XML telegram. Note however, that any processing instructions or XML version statements must be avoided, since it may cause
  287. the XML stream to become invalid XML. If this is a problem, normal <strong>text</strong> encoding can be used as an alternative. The advantage of <strong>xml</strong>
  288. instead of <strong>text</strong> or <strong>base64</strong> encodings is when used in conjunction with EXI compression &xep0322;. EXI compression has the ability to
  289. compress XML efficiently. Text will not be compressed, unless response exists in internal string tables. Base-64 encoded data will be compressed so that the 33%
  290. size gain induced by the encoding is recaptured.
  291. </p>
  292. </dd>
  293. </di>
  294. <di>
  295. <dt>base64</dt>
  296. <dd>
  297. <p>
  298. Base-64 encoded binary content. Can be used to easily embed binary content in the telegram.
  299. </p>
  300. </dd>
  301. </di>
  302. <di>
  303. <dt>chunkedBase64</dt>
  304. <dd>
  305. <p>
  306. Chunked Base-64 encoded binary content. The content is not embedded in the telegram. Instead it is sent in chunks, using separate
  307. <strong>chunk</strong> messages to the client. Chunked transport can be used by the server when it doesn't know the size of the final result.
  308. Streaming content, i.e. content of infinite length, must use <strong>ibb</strong> or <strong>jingle</strong> transport types to transfer content.
  309. If the content consists of a file, <strong>sipub</strong> should be used.
  310. </p>
  311. <p>
  312. Chunked encoding is perfect for dynamic responses of moderate sizes, for instance for API method responses. The server does not know when the response
  313. is begun to be generated what the final size will be, but it will be most probably "manageable". Using the chunked transfer mechanism enables the
  314. server to start sending the content, minimizing the need for buffers, and at the same time minimizing the number of messages that needs to be sent,
  315. increasing throughput.
  316. </p>
  317. <p>
  318. The client can limit the maximum chunk size to be used by the server, using the <strong>maxChunkSize</strong> attribute in the request. The chunk
  319. size can be set to a value between 256 and 65536. If not provided in the request, the server chooses an appropriate value. Note that chunks can
  320. be sent containing a smaller amount of bytes than the maximum chunk size provided in the request.
  321. </p>
  322. </dd>
  323. </di>
  324. <di>
  325. <dt>sipub</dt>
  326. <dd>
  327. <p>
  328. The sender might deem the content to be too large for sending embedded in the XMPP telegram. To circumnavigate this, the sender publishes
  329. the content as a file using &xep0137; (Publishing Stream Initiation Requests), instead of embedding the content directly. This might be the case for instance, when
  330. a client requests a video resource, without using a ranged request.
  331. </p>
  332. <p>
  333. This transfer mechanism is of course the logical choice, if the content is already stored in a file on the server, and the size of the file
  334. is sufficiently large to merit the overhead of sipub. Smaller files can simply be returned using the <strong>text</strong>, <strong>xml</strong>
  335. or <strong>base64</strong> mechanisms.
  336. </p>
  337. <p>
  338. The client can disable the use of <strong>sipub</strong> by the server, by including a <strong>sipub='false'</strong> attribute in the request.
  339. <strong>sipub</strong> is enabled by default. On constrained devices with limited support for different XEP's, this can be a way to avoid the
  340. use of technologies not supported by the client.
  341. </p>
  342. </dd>
  343. </di>
  344. <di>
  345. <dt>ibb</dt>
  346. <dd>
  347. <p>
  348. This option may be used to encode indefinite streams, like live audio or video streams (HLS, SHOUTcast, Motion JPeg web cams, etc).
  349. It uses &xep0047; to send the content over an in-band bytestream to the client. This option is not available in requests, only in responses.
  350. </p>
  351. <p>
  352. Streams must not use any of the above mechanisms. Only <strong>ibb</strong> and <strong>jingle</strong> mechanisms can be used. If the content
  353. represents multimedia <strong>jingle</strong> is preferrable, especially if different encodings are available.
  354. </p>
  355. <p>
  356. The client can disable the use of <strong>ibb</strong> by the server, by including a <strong>ibb='false'</strong> attribute in the request.
  357. <strong>ibb</strong> is enabled by default. On constrained devices with limited support for different XEP's, this can be a way to avoid the
  358. use of technologies not supported by the client.
  359. </p>
  360. </dd>
  361. </di>
  362. <di>
  363. <dt>jingle</dt>
  364. <dd>
  365. <p>
  366. For demanding multi-media streams alternative methods to transport streaming rather than embedded into the XMPP stream may be
  367. required. Even though the <strong>ibb</strong> method may be sufficient to stream a low-resolution web cam in the home, or listen to a microphone
  368. or a radio station, it is probably badly suited for high-resolution video streams with multiple video angles and audio channels. If such content is accessed
  369. and streamed, the server can negotiate a different way to stream the content using &xep0166;.
  370. </p>
  371. <p>
  372. The client can disable the use of <strong>ingle</strong> by the server, by including a <strong>jingle='false'</strong> attribute in the request.
  373. <strong>jingle</strong> is enabled by default. On constrained devices with limited support for different XEP's, this can be a way to avoid the
  374. use of technologies not supported by the client.
  375. </p>
  376. </dd>
  377. </di>
  378. </dl>
  379. <p>
  380. <strong>Note:</strong> Content encoded using <strong>chunkedBase64</strong> encoding method can be terminated, either by the receptor going off-line, or by
  381. sending a <strong>close</strong> command to the sender. The transfer methods <strong>sipub</strong>, <strong>ibb</strong> and <strong>jingle</strong> have
  382. their own mechanisms for aborting content transfer.
  383. </p>
  384. <section2 topic='HTTP Methods'>
  385. <p>
  386. The following use cases show how different HTTP methods may work when transported over XMPP. To facilitate the readability in these examples,
  387. simple text or xml results are shown.
  388. </p>
  389. <section3 topic='OPTIONS' anchor='OPTIONS'>
  390. <p>
  391. This section shows an example of an OPTIONS method call. OPTIONS is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.2'>§9.2 in RFC 2616</link>.
  392. </p>
  393. <example caption='OPTIONS'>
  394. <![CDATA[
  395. <iq type='set'
  396. from='httpclient@example.org/browser'
  397. to='httpserver@example.org'
  398. id='1'>
  399. <req xmlns='urn:xmpp:http' method='OPTIONS' resource='*' version='1.1'>
  400. <headers xmlns='http://jabber.org/protocol/shim'>
  401. <header name='Host'>example.org</header>
  402. </headers>
  403. </req>
  404. </iq>
  405. <iq type='result'
  406. from='httpserver@example.org'
  407. to='httpclient@example.org/browser'
  408. id='1'>
  409. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  410. <headers xmlns='http://jabber.org/protocol/shim'>
  411. <header name='Date'>Fri, 03 May 2013 13:52:10 GMT-4</header>
  412. <header name='Allow'>OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE</header>
  413. <header name='Content-Length'>0</header>
  414. </headers>
  415. </resp>
  416. </iq>]]>
  417. </example>
  418. </section3>
  419. <section3 topic='GET' anchor='GET'>
  420. <p>
  421. This section shows an example of a GET method call. GET is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.3'>§9.3 in RFC 2616</link>.
  422. </p>
  423. <example caption='GET'>
  424. <![CDATA[
  425. <iq type='set'
  426. from='httpclient@example.org/browser'
  427. to='httpserver@example.org'
  428. id='2'>
  429. <req xmlns='urn:xmpp:http' method='GET' resource='/rdf/xep' version='1.1'>
  430. <headers xmlns='http://jabber.org/protocol/shim'>
  431. <header name='Host'>example.org</header>
  432. </headers>
  433. </req>
  434. </iq>
  435. <iq type='result'
  436. from='httpserver@example.org'
  437. to='httpclient@example.org/browser'
  438. id='2'>
  439. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  440. <headers xmlns='http://jabber.org/protocol/shim'>
  441. <header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
  442. <header name='Server'>Clayster</header>
  443. <header name='Content-Type'>text/turtle</header>
  444. <header name='Content-Length'>...</header>
  445. <header name='Connection'>Close</header>
  446. </headers>
  447. <data>
  448. <text>@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt;.
  449. @base &lt;http://example.org/&gt;.
  450. &lt;xep&gt; dc:title "HTTP over XMPP";
  451. dc:creator &lt;PeterWaher&gt;;
  452. dc:publisher &lt;XSF&gt;.</text>
  453. </data>
  454. </resp>
  455. </iq>]]>
  456. </example>
  457. <p>
  458. <strong>Note:</strong> The XMPP/HTTP bridge at the server only transmits headers literally as they are reported, as if it was normal HTTP over TCP
  459. that was used. In the HTTP over XMPP case, connections are not handled in the same way, and so the "Connection: Close" header has no meaning in this
  460. case. For more information about connection handling in the HTTP over XMPP case, see the section on <link url='#httpconnections'>Connection Handling</link>.
  461. </p>
  462. </section3>
  463. <section3 topic='HEAD' anchor='HEAD'>
  464. <p>
  465. This section shows an example of a HEAD method call. HEAD is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.4'>§9.4 in RFC 2616</link>.
  466. </p>
  467. <example caption='HEAD'>
  468. <![CDATA[
  469. <iq type='set'
  470. from='httpclient@example.org/browser'
  471. to='httpserver@example.org'
  472. id='3'>
  473. <req xmlns='urn:xmpp:http' method='HEAD' resource='/video/video1.m4' version='1.1'>
  474. <headers xmlns='http://jabber.org/protocol/shim'>
  475. <header name='Host'>example.org</header>
  476. </headers>
  477. </req>
  478. </iq>
  479. <iq type='result'
  480. from='httpserver@example.org'
  481. to='httpclient@example.org/browser'
  482. id='3'>
  483. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  484. <headers xmlns='http://jabber.org/protocol/shim'>
  485. <header name='Date'>Fri, 03 May 2013 16:57:12GMT-4</header>
  486. <header name='Server'>Clayster</header>
  487. <header name='Content-Type'>video/mp4</header>
  488. <header name='Content-Length'>12345678</header>
  489. </headers>
  490. </resp>
  491. </iq>]]>
  492. </example>
  493. </section3>
  494. <section3 topic='POST' anchor='POST'>
  495. <p>
  496. This section shows an example of a POST method call. POST is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.5'>§9.5 in RFC 2616</link>.
  497. </p>
  498. <example caption='POST'>
  499. <![CDATA[
  500. <iq type='set'
  501. from='httpclient@example.org/browser'
  502. to='httpserver@example.org'
  503. id='4'>
  504. <req xmlns='urn:xmpp:http' method='POST' resource='/sparql/?default-graph-uri=http%3A%2F%2Fexample.org%2Frdf/xep' version='1.1'>
  505. <headers xmlns='http://jabber.org/protocol/shim'>
  506. <header name='Host'>example.org</header>
  507. <header name='User-agent'>Clayster HTTP/XMPP Client</header>
  508. <header name='Content-Type'>application/sparql-query</header>
  509. <header name='Content-Length'>...</header>
  510. </headers>
  511. <data>
  512. <text>PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
  513. BASE &lt;http://example.org/&gt;
  514. SELECT ?title ?creator ?publisher
  515. WHERE { ?x dc:title ?title .
  516. OPTIONAL { ?x dc:creator ?creator } .
  517. }</text>
  518. </data>
  519. </req>
  520. </iq>
  521. <iq type='result'
  522. from='httpserver@example.org'
  523. to='httpclient@example.org/browser'
  524. id='4'>
  525. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  526. <headers xmlns='http://jabber.org/protocol/shim'>
  527. <header name='Date'>Fri, 03 May 2013 17:09:34-4</header>
  528. <header name='Server'>Clayster</header>
  529. <header name='Content-Type'>application/sparql-results+xml</header>
  530. <header name='Content-Length'>...</header>
  531. </headers>
  532. <data>
  533. <xml>
  534. <sparql xmlns="http://www.w3.org/2005/sparql-results#">
  535. <head>
  536. <variable name="title"/>
  537. <variable name="creator"/>
  538. </head>
  539. <results>
  540. <result>
  541. <binding name="title">
  542. <literal>HTTP over XMPP</literal>
  543. </binding>
  544. <binding name="creator">
  545. <uri>http://example.org/PeterWaher</uri>
  546. </binding>
  547. </result>
  548. </results>
  549. </sparql>
  550. </xml>
  551. </data>
  552. </resp>
  553. </iq>]]>
  554. </example>
  555. <p>
  556. <strong>Note:</strong> If using <strong>xml</strong> encoding of data, care has to be taken to avoid including the version and encoding information
  557. (&lt;?xml version="1.0"?&gt;) at the top of the document, otherwise the resulting XML will be invalid. Care has also to be taken to make sure that the
  558. generated XML is not invalid XMPP, even though it might be valid XML. This could happen for instance, if the XML contains illegal elements from the
  559. jabber:client namespace. If in doubt, use another encoding mechanism.
  560. </p>
  561. </section3>
  562. <section3 topic='PUT' anchor='PUT'>
  563. <p>
  564. This section shows an example of a PUT method call. PUT is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.6'>§9.6 in RFC 2616</link>.
  565. </p>
  566. <example caption='PUT'>
  567. <![CDATA[
  568. <iq type='set'
  569. from='httpclient@example.org/browser'
  570. to='httpserver@example.org'
  571. id='5'>
  572. <req xmlns='urn:xmpp:http' method='PUT' resource='/index.html' version='1.1'>
  573. <headers xmlns='http://jabber.org/protocol/shim'>
  574. <header name='Host'>example.org</header>
  575. <header name='Content-Type'>text/html</header>
  576. <header name='Content-Length'>...</header>
  577. </headers>
  578. <data>
  579. <text>&lt;html&gt;&lt;header/&gt;&lt;body&gt;&lt;p&gt;Beautiful home page.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</text>
  580. </data>
  581. </req>
  582. </iq>
  583. <iq type='result'
  584. from='httpserver@example.org'
  585. to='httpclient@example.org/browser'
  586. id='5'>
  587. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='204' statusMessage='No Content'>
  588. <headers xmlns='http://jabber.org/protocol/shim'>
  589. <header name='Date'>Fri, 03 May 2013 17:40:41GMT-4</header>
  590. <header name='Content-Length'>0</header>
  591. </headers>
  592. </resp>
  593. </iq>]]>
  594. </example>
  595. </section3>
  596. <section3 topic='DELETE' anchor='DELETE'>
  597. <p>
  598. This section shows an example of a DELETE method call. DELETE is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.7'>§9.7 in RFC 2616</link>.
  599. </p>
  600. <example caption='DELETE'>
  601. <![CDATA[
  602. <iq type='set'
  603. from='httpclient@example.org/browser'
  604. to='httpserver@example.org'
  605. id='6'>
  606. <req xmlns='urn:xmpp:http' method='DELETE' resource='/index.html' version='1.1'>
  607. <headers xmlns='http://jabber.org/protocol/shim'>
  608. <header name='Host'>example.org</header>
  609. </headers>
  610. </req>
  611. </iq>
  612. <iq type='result'
  613. from='httpserver@example.org'
  614. to='httpclient@example.org/browser'
  615. id='6'>
  616. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='403' statusMessage='Forbidden'>
  617. <headers xmlns='http://jabber.org/protocol/shim'>
  618. <header name='Date'>Fri, 03 May 2013 17:46:07GMT-4</header>
  619. <header name='Content-Type'>text/plain</header>
  620. <header name='Content-Length'>...</header>
  621. </headers>
  622. <data>
  623. <text>You're not allowed to change the home page!</text>
  624. </data>
  625. </resp>
  626. </iq>]]>
  627. </example>
  628. </section3>
  629. <section3 topic='TRACE' anchor='TRACE'>
  630. <p>
  631. This section shows an example of a TRACE method call. TRACE is described in <link url='http://tools.ietf.org/html/rfc2616#section-9.8'>§9.8 in RFC 2616</link>.
  632. </p>
  633. <example caption='TRACE'>
  634. <![CDATA[
  635. <iq type='set'
  636. from='httpclient@example.org/browser'
  637. to='httpserver@example.org'
  638. id='7'>
  639. <req xmlns='urn:xmpp:http' method='TRACE' resource='/rdf/ex1.turtle' version='1.1'>
  640. <headers xmlns='http://jabber.org/protocol/shim'>
  641. <header name='Host'>example.org</header>
  642. </headers>
  643. </req>
  644. </iq>
  645. <iq type='result'
  646. from='httpserver@example.org'
  647. to='httpclient@example.org/browser'
  648. id='7'>
  649. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  650. <headers xmlns='http://jabber.org/protocol/shim'>
  651. <header name='Date'>Fri, 03 May 2013 17:55:10GMT-4</header>
  652. <header name='Server'>Clayster</header>
  653. <header name='Content-Type'>message/http</header>
  654. <header name='Content-Length'>...</header>
  655. </headers>
  656. <data>
  657. <text>GET /rdf/ex1.turtle HTTP/1.1
  658. Host: example.org</text>
  659. </data>
  660. </resp>
  661. </iq>]]>
  662. </example>
  663. <p>
  664. <strong>Note:</strong> The Trace command returns the request it received from the client by the server. Here, however, it is assumed that the request
  665. is made over HTTP/TCP, not HTTP/XMPP. Therefore, in this example, the XMPP layer has transformed the HTTP/XMPP request into an HTTP/TCP-looking
  666. request, which is returned as the response to the TRACE Method call. RFC 2616 is silent to the actual format of the TRACE response
  667. (MIME TYPE message/http), and TRACE is only used (if not disabled for security reasons) for debugging connections and routing via proxies.
  668. Therefore, a response returning the original XMPP request should also be accepted by the caller.
  669. </p>
  670. </section3>
  671. <section3 topic='PATCH' anchor='PATCH'>
  672. <p>
  673. This section shows an example of a PATCH method call. PATCH is described in <link url='http://tools.ietf.org/html/rfc5789'>RFC 5789</link>.
  674. </p>
  675. <example caption='PATCH'>
  676. <![CDATA[
  677. <iq type='set'
  678. from='httpclient@example.org/browser'
  679. to='httpserver@example.org'
  680. id='8'>
  681. <req xmlns='urn:xmpp:http' method='PATCH' resource='/file.txt' version='1.1'>
  682. <headers xmlns='http://jabber.org/protocol/shim'>
  683. <header name='Host'>www.example.com</header>
  684. <header name='Content-Type'>application/example</header>
  685. <header name='If-Match'>e0023aa4e</header>
  686. <header name='Content-Length'>100</header>
  687. </headers>
  688. <data>
  689. [description of changes]
  690. </data>
  691. </req>
  692. </iq>
  693. <iq type='result'
  694. from='httpserver@example.org'
  695. to='httpclient@example.org/browser'
  696. id='8'>
  697. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='204' statusMessage='No Content'>
  698. <headers xmlns='http://jabber.org/protocol/shim'>
  699. <header name='Content-Location'>/file.txt</header>
  700. <header name='ETag'>e0023aa4e</header>
  701. </headers>
  702. </resp>
  703. </iq>]]>
  704. </example>
  705. </section3>
  706. </section2>
  707. <section2 topic='Encoding formats' anchor='encoding'>
  708. <p>
  709. In the following sub-sections, the different data encoding formats are discussed, each with corresponding examples to illustrate how they work.
  710. The interesting part of these examples is the <strong>data</strong> element and its contents.
  711. </p>
  712. <section3 topic='text'>
  713. <p>
  714. Text responses is a simple way to return text responses (i.e. any MIME Type starting with text/). Since the text is embedded into XML, the
  715. characters &lt;, &gt; and &amp; need to be escaped to &amp;lt;, &amp;gt; and &amp;amp; respectively.
  716. </p>
  717. <p>
  718. The following example shows how a TURTLE response, which is text-based, is returned using the <strong>text</strong> encoding:
  719. </p>
  720. <example caption='text'>
  721. <![CDATA[
  722. <iq type='result'
  723. from='httpserver@example.org'
  724. to='httpclient@example.org/browser'
  725. id='2'>
  726. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  727. <headers xmlns='http://jabber.org/protocol/shim'>
  728. <header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
  729. <header name='Server'>Clayster</header>
  730. <header name='Content-Type'>text/turtle</header>
  731. <header name='Content-Length'>...</header>
  732. <header name='Connection'>Close</header>
  733. </headers>
  734. <data>
  735. <text>@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt;.
  736. @base &lt;http://example.org/&gt;.
  737. &lt;xep&gt; dc:title "HTTP over XMPP";
  738. dc:creator &lt;PeterWaher&gt;;
  739. dc:publisher &lt;XSF&gt;.</text>
  740. </data>
  741. </resp>
  742. </iq>]]>
  743. </example>
  744. </section3>
  745. <section3 topic='xml'>
  746. <p>
  747. XML is a convenient way to return XML embedded in the XMPP response. This can be suitable for MIME Types of the form <strong>.*/(.*[+])?xml</strong>
  748. (using regular expression to match them), like text/xml, application/soap+xml or application/sparql-results+xml. Care has to be taken however, since
  749. not all XML constructs can be embedded as content to an XML element without invalidating it, like the xml version and encoding declaration
  750. (&lt;?xml version="1.0"?&gt; as an example). Care has also to be taken to make sure that the generated XML is not invalid XMPP, even though it might
  751. be valid XML. This could happen for instance, if the XML contains illegal elements from the jabber:client namespace.
  752. </p>
  753. <p>
  754. If unsure how to handle XML responses using the <strong>xml</strong> encoding type, you can equally well use the <strong>text</strong> type, but
  755. encode the XML escape characters &lt;, &gt; and &amp;, or use another encoding, like <strong>base64</strong>.
  756. </p>
  757. <p>
  758. The advantage of <strong>xml</strong> instead of <strong>text</strong> or <strong>base64</strong> encodings is when used in conjunction with
  759. <link url='http://xmpp.org/extensions/xep-0322.html'>EXI compression</link>. EXI compression has the ability to compress XML efficiently.
  760. Text will not be compressed, unless response exists in internal string tables. Base-64 encoded data will be compressed so that the 33% size
  761. gain induced by the encoding is recaptured.
  762. </p>
  763. <example caption='xml'>
  764. <![CDATA[
  765. <iq type='result'
  766. from='httpserver@example.org'
  767. to='httpclient@example.org/browser'
  768. id='4'>
  769. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  770. <headers xmlns='http://jabber.org/protocol/shim'>
  771. <header name='Date'>Fri, 03 May 2013 17:09:34-4</header>
  772. <header name='Server'>Clayster</header>
  773. <header name='Content-Type'>application/sparql-results+xml</header>
  774. <header name='Content-Length'>...</header>
  775. </headers>
  776. <data>
  777. <xml>
  778. <sparql xmlns="http://www.w3.org/2005/sparql-results#">
  779. <head>
  780. <variable name="title"/>
  781. <variable name="creator"/>
  782. </head>
  783. <results>
  784. <result>
  785. <binding name="title">
  786. <literal>HTTP over XMPP</literal>
  787. </binding>
  788. <binding name="creator">
  789. <uri>http://example.org/PeterWaher</uri>
  790. </binding>
  791. </result>
  792. </results>
  793. </sparql>
  794. </xml>
  795. </data>
  796. </resp>
  797. </iq>]]>
  798. </example>
  799. </section3>
  800. <section3 topic='base64'>
  801. <p>
  802. Base-64 encoding is a simple way to encode content that is easily embedded into XML. Apart from the advantage of being easy to encode,
  803. it has the disadvantage to increase the size of the content by 33%, since it requires 4 bytes to encode 3 bytes of data.
  804. Care has to be taken not to send too large items using this encoding.
  805. </p>
  806. <p>
  807. <strong>Note:</strong> The actual size of the content being sent does not necessarily need to increase if this encoding method is used.
  808. If EXI compression is used at the same time, and it uses schema-aware compression, it will actually understand that the character set used
  809. to encode the data only uses 6 bits of information per character, and thus compresses the data back to its original size.
  810. </p>
  811. <p>
  812. The following example shows an image is returned using the <strong>base64</strong> encoding:
  813. </p>
  814. <example caption='base64'>
  815. <![CDATA[
  816. <iq type='result'
  817. from='httpserver@example.org'
  818. to='httpclient@example.org/browser'
  819. id='9'>
  820. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  821. <headers xmlns='http://jabber.org/protocol/shim'>
  822. <header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
  823. <header name='Server'>Clayster</header>
  824. <header name='Content-Type'>image/png</header>
  825. <header name='Content-Length'>221203</header>
  826. </headers>
  827. <data>
  828. <base64>iVBORw0KGgoAAAANSUhEUgAAASwAAAGQCAYAAAAUdV17AAAAAXNSR0 ... tVWJd+e+y1AAAAABJRU5ErkJggg==</base64>
  829. </data>
  830. </resp>
  831. </iq>]]>
  832. </example>
  833. </section3>
  834. <section3 topic='chunkedBase64'>
  835. <p>
  836. In HTTP, Chunked Transfer Encoding is used when the sender does not know the size of the content being sent, and to avoid having its buffers
  837. overflow, sends the content in chunks with a definite size.
  838. </p>
  839. <p>
  840. A similar method exists in the HTTP over XMPP transport: The <strong>chunkedBase64</strong> allows the sender to transmit the content in chunks.
  841. Every chunk is base-64 encoded. The stream of chunks are identified by a <strong>streamId</strong> parameter, since chunks from different responses
  842. may be transmitted at the same time.
  843. </p>
  844. <p>
  845. Another difference between normal chunked transport, and the <strong>chunkedBase64</strong> encoding, is that the size of chunks does not have to be
  846. predetermined. Chunks are naturally delimited and embedded in the XML stanza. The last chunk in a response must have the <strong>last</strong>
  847. attribute set to true.
  848. </p>
  849. <example caption='chunkedBase64'>
  850. <![CDATA[
  851. <iq type='result'
  852. from='httpserver@example.org'
  853. to='httpclient@example.org/browser'
  854. id='10'>
  855. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  856. <headers xmlns='http://jabber.org/protocol/shim'>
  857. <header name='Date'>Fri, 04 May 2013 13:43:12GMT-4</header>
  858. <header name='Server'>Clayster</header>
  859. <header name='Content-Type'>image/png</header>
  860. <header name='Content-Length'>221203</header>
  861. </headers>
  862. <data>
  863. <chunkedBase64 streamId='Stream0001'/>
  864. </data>
  865. </resp>
  866. </iq>
  867. <message from='httpserver@example.org'
  868. to='httpclient@example.org/browser'>
  869. <chunk xmlns='urn:xmpp:http' streamId='Stream0001' nr='0'>iVBORw0KGgoAAAANSUhEUgAAASwAAAGQCAYAA ...</chunk>
  870. </message>
  871. ...
  872. <message from='httpserver@example.org'
  873. to='httpclient@example.org/browser'>
  874. <chunk xmlns='urn:xmpp:http' streamId='Stream0001' nr='5' last='true'>... 2uPzi9u+tVWJd+e+y1AAAAABJRU5ErkJggg==</chunk>
  875. </message>]]>
  876. </example>
  877. <p>
  878. <strong>Note:</strong> Chunked encoding assumes the content to be finite. If content is infinite (i.e. for instance live streaming),
  879. the <strong>ibb</strong> or <strong>jingle</strong> transfer encodings must be used instead. If the sender is unsure if the content is
  880. finite or infinite, <strong>ibb</strong> or <strong>jingle</strong> must be used.
  881. </p>
  882. <p>
  883. <strong>Note 2:</strong> If the web server sends chunked data to the client it uses the HTTP header <strong>Transfer-Encoding: chunked</strong>,
  884. and then sends the data in chunks but with chunk sizes inserted so the receiving end can decode the incoming data. Note that this data will
  885. be included in the data sent in the XMPP chunks defined by this document. In this case, data will be chunked twice: First by the web server,
  886. and then by the HTTP over XMPP transport layer. When received by the client, it is first reassembled by the HTTP over XMPP layer on the client,
  887. and then by the HTTP client who will read the original chunk size elements inserted into the content. More information about HTTP chunking,
  888. can be found in <link url='http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1'>RDF2616 §3.6.1</link>.
  889. </p>
  890. <p>
  891. <strong>Note 3:</strong> In order to work over XMPP servers that do not maintain message order, a <strong>nr</strong> attribute is available on the
  892. <strong>chunk</strong> element. The first chunk reports a <strong>nr</strong> of zero. Each succcessive chunk reports a <strong>nr</strong> that is
  893. incremented by one. In this way, the receiver can make sure to order incoming chunks in the correct order.
  894. </p>
  895. </section3>
  896. <section3 topic='sipub'>
  897. <p>
  898. Often content being sent can be represented by a file, virtual or real, especially if the content actually represents a file and is not
  899. dynamically generated. In these instances, instead of embedding the contents in the response,
  900. since content can be potentially huge, a File Stream Initiation is returned instead, as defined in
  901. <link url='http://xmpp.org/extensions/xep-0137.html'>XEP 0137: Publishing Stream Initiation Requests</link>. This is done using the
  902. <strong>sipub</strong> element.
  903. </p>
  904. <example caption='sipub'>
  905. <![CDATA[
  906. <iq type='result'
  907. from='httpserver@example.org'
  908. to='httpclient@example.org/browser'
  909. id='11'>
  910. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  911. <headers xmlns='http://jabber.org/protocol/shim'>
  912. <header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
  913. <header name='Server'>Clayster</header>
  914. <header name='Content-Type'>image/png</header>
  915. <header name='Content-Length'>221203</header>
  916. </headers>
  917. <data>
  918. <sipub xmlns='http://jabber.org/protocol/sipub'
  919. from='httpserver@example.org'
  920. id='file-0001'
  921. mime-type='image/png'
  922. profile='http://jabber.org/protocol/si/profile/file-transfer'>
  923. <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
  924. name='Kermit.png'
  925. size='221203'
  926. date='2013-03-06T16:47Z'/>
  927. </sipub>
  928. </data>
  929. </resp>
  930. </iq>]]>
  931. </example>
  932. </section3>
  933. <section3 topic='ibb' anchor='#streams'>
  934. <p>
  935. Some web servers provide streaming content, i.e. content where packets are sent according to a timely fashion. Examples are video
  936. and audio streams like HLS (HTTP Live Streams), SHOUTcast, ICEcast, Motion JPeg, etc. In all these examples, content is infinite,
  937. and cannot be sent "all as quickly as possible". Instead, content is sent according to some kind of bitrate or frame rate for
  938. example.
  939. </p>
  940. <p>
  941. Such content must use the <strong>ibb</strong> transfer mechanism, if used (or the <strong>jingle</strong> transfer machanism).
  942. The <strong>ibb</strong> transfer mechanism uses <link url='http://xmpp.org/extensions/xep-0047.html'>In-Band Bytestreams</link>
  943. to transfer data from the server to the client. It starts by sending an a <strong>ibb</strong> element containing a <strong>sid</strong>
  944. attribute identifying the stream. Then the server sends an <strong>ibb:open</strong> IQ-stanza to the client according to
  945. <link url='http://xmpp.org/extensions/xep-0047.html'>XEP-0047</link>. The client can choose to reject, negotiate or acceopt the request
  946. whereby the transfer is begun. When the client is satisified and wants to close the stream, it does so, also according to
  947. <link url='http://xmpp.org/extensions/xep-0047.html'>XEP-0047</link>. The <strong>sid</strong> value returned in the HTTP response
  948. is the same <strong>sid</strong> value that is later used by the IBB messages that follow. In this way, the client can relate
  949. the HTTP request and response, with the corresponding data transferred separately.
  950. </p>
  951. <example caption='ibb'>
  952. <![CDATA[
  953. <iq type='set'
  954. from='httpclient@example.org/browser'
  955. to='httpserver@example.org'
  956. id='12'>
  957. <req xmlns='urn:xmpp:http' method='GET' resource='/webcam1.jpg' version='1.1'>
  958. <headers xmlns='http://jabber.org/protocol/shim'>
  959. <header name='Host'>example.org</header>
  960. </headers>
  961. </req>
  962. </iq>
  963. <iq type='result'
  964. from='httpserver@example.org'
  965. to='httpclient@example.org/browser'
  966. id='12'>
  967. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  968. <headers xmlns='http://jabber.org/protocol/shim'>
  969. <header name='Date'>Fri, 04 May 2013 15:05:32GMT-4</header>
  970. <header name='Server'>Clayster</header>
  971. <header name='Content-Type'>multipart/x-mixed-replace;boundary=__2347927492837489237492837</header>
  972. </headers>
  973. <data>
  974. <ibb sid='Stream0002'/>
  975. </data>
  976. </resp>
  977. </iq>
  978. <iq type='set'
  979. from='httpserver@example.org'
  980. to='httpclient@example.org/browser'
  981. id='13'>
  982. <open xmlns='http://jabber.org/protocol/ibb'
  983. block-size='32768'
  984. sid='Stream0002'
  985. stanza='message'/>
  986. </iq>
  987. <iq type='result'
  988. from='httpclient@example.org/browser'
  989. to='httpserver@example.org'
  990. id='13'/>
  991. <message from='httpserver@example.org'
  992. to='httpclient@example.org/browser'>
  993. <data xmlns='http://jabber.org/protocol/ibb' sid='Stream0002' seq='0'>...</chunk>
  994. </message>
  995. ...
  996. <iq type='set'
  997. from='httpclient@example.org/browser'
  998. to='httpserver@example.org'
  999. id='14'>
  1000. <close xmlns='http://jabber.org/protocol/ibb' sid='Stream0002'/>
  1001. </iq>
  1002. <iq type='result'
  1003. from='httpserver@example.org'
  1004. to='httpclient@example.org/browser'
  1005. id='14'/>]]>
  1006. </example>
  1007. </section3>
  1008. <section3 topic='jingle' anchor='jingle'>
  1009. <p>
  1010. For demanding multi-media streams alternative methods to transport streaming rather than embedded into the XMPP stream may be
  1011. required. Even though the <strong>ibb</strong> method may be sufficient to stream a low-resolution web cam in the home, or listen to a microphone
  1012. or a radio station, it is probably badly suited for high-resolution video streams with multiple video angles and audio channels. If such content is accessed
  1013. and streamed, the server can negotiate a different way to stream the content using <link url='http://xmpp.org/extensions/xep-0166.html'>XEP 0166: Jingle</link>.
  1014. </p>
  1015. <example caption='jingle'>
  1016. <![CDATA[
  1017. <iq type='result'
  1018. from='httpserver@example.org'
  1019. to='httpclient@example.org/browser'
  1020. id='14'>
  1021. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  1022. <headers xmlns='http://jabber.org/protocol/shim'>
  1023. <header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
  1024. <header name='Server'>Clayster</header>
  1025. <header name='Content-Type'>video/mp4</header>
  1026. <header name='Content-Length'>...</header>
  1027. </headers>
  1028. <data>
  1029. <jingle xmlns='urn:xmpp:jingle:1'
  1030. action='session-initiate'
  1031. initiator='romeo@montague.lit/orchard'
  1032. sid='a73sjjvkla37jfea'>
  1033. <content creator='initiator' name='voice'>
  1034. <description xmlns='urn:xmpp:jingle:apps:rtp:1' media='audio'>
  1035. <payload-type id='96' name='speex' clockrate='16000'/>
  1036. <payload-type id='97' name='speex' clockrate='8000'/>
  1037. <payload-type id='18' name='G729'/>
  1038. <payload-type id='0' name='PCMU' />
  1039. <payload-type id='103' name='L16' clockrate='16000' channels='2'/>
  1040. <payload-type id='98' name='x-ISAC' clockrate='8000'/>
  1041. </description>
  1042. <transport xmlns='urn:xmpp:jingle:transports:ice-udp:1'
  1043. pwd='asd88fgpdd777uzjYhagZg'
  1044. ufrag='8hhy'>
  1045. <candidate component='1'
  1046. foundation='1'
  1047. generation='0'
  1048. id='el0747fg11'
  1049. ip='10.0.1.1'
  1050. network='1'
  1051. port='8998'
  1052. priority='2130706431'
  1053. protocol='udp'
  1054. type='host'/>
  1055. <candidate component='1'
  1056. foundation='2'
  1057. generation='0'
  1058. id='y3s2b30v3r'
  1059. ip='192.0.2.3'
  1060. network='1'
  1061. port='45664'
  1062. priority='1694498815'
  1063. protocol='udp'
  1064. rel-addr='10.0.1.1'
  1065. rel-port='8998'
  1066. type='srflx'/>
  1067. </transport>
  1068. </content>
  1069. </jingle>
  1070. </data>
  1071. </resp>
  1072. </iq>]]>
  1073. </example>
  1074. <p>
  1075. <strong>Note:</strong> Example taken from <link url='http://xmpp.org/extensions/xep-0166.html#howitworks'>XEP 166: Jingle</link>.
  1076. </p>
  1077. <p>
  1078. <strong>Note2:</strong> Using Jingle in this way makes it possible for an intelligent server to return multiple streams the client
  1079. can choose from, something that is not done in normal HTTP over TCP. The first candidate should however correspond to the same stream
  1080. that would have been returned if the request had been made using normal HTTP over TCP.
  1081. </p>
  1082. </section3>
  1083. </section2>
  1084. <section2 topic='Applications'>
  1085. <p>
  1086. The following section lists use cases based on type of application. It is used to illustrate what types of applications would benefit from
  1087. implementing this extension.
  1088. </p>
  1089. <section3 topic='Browsers'>
  1090. <p>
  1091. HTTP began as a protocol for presenting text in browsers. So, browsers is a natural place to start to list use cases for this extensions.
  1092. In general, content is identified using URL's, and in the browser a user enters the URL into Address Field of the browser, and the corresponding
  1093. content is displayed in the display area. The content itself will probably contain links to other content, each such item identified
  1094. by an absolute or relative URL.
  1095. </p>
  1096. <section4 topic='httpx scheme' anchor='httpxscheme'>
  1097. <p>
  1098. The syntax and format of Uniform Resource Locators (URLs) or Uniform Resource Identifiers (URIs) is defined in &rfc3986;. The basic format is
  1099. defined as follows:
  1100. </p>
  1101. <example caption='URL syntax'>
  1102. <![CDATA[
  1103. URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
  1104. hier-part = "//" authority path-abempty
  1105. / path-absolute
  1106. / path-rootless
  1107. / path-empty]]>
  1108. </example>
  1109. <p>
  1110. &rfc2616; furthermore defines the format of URLs using the http URI scheme, as follows:
  1111. </p>
  1112. <example caption='HTTP (over TCP) URL syntax'>
  1113. <![CDATA[
  1114. http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]]]>
  1115. </example>
  1116. <p>
  1117. &rfc2818; continues to define the https scheme for HTTP transport over SSL/TLS over TCP using the same format as for HTTP URLs, except the
  1118. https scheme is used to inform the client that HTTP over SSL/TLS is to be used.
  1119. </p>
  1120. <p>
  1121. In a similar way, this document proposes a new URI scheme: <strong>httpx</strong>, based on the HTTP URL scheme, except
  1122. <strong>httpx</strong> URLs imply the use of HTTP over XMPP instead of HTTP over TCP. URLs using the <strong>httpx</strong>
  1123. URL scheme has the following format:
  1124. </p>
  1125. <example caption='HTTP over XMPP URL syntax'>
  1126. <![CDATA[
  1127. httpx_URL = "httpx:" "//" resourceless_jid [ abs_path [ "?" query ]]]]>
  1128. </example>
  1129. <p>
  1130. Here, the host and port parts of normal HTTP URLs have been replaced by the resource-less JID of the HTTP Server, i.e. only the user name,
  1131. the @ character and the domain. The / separator between the resource-less JID and the following abs_path, is part of abs_path.
  1132. </p>
  1133. <example caption='Examples of URLs with the httpx scheme'>
  1134. <![CDATA[
  1135. httpx://httpServer@example.org/index.html
  1136. httpx://httpServer@example.org/images/image1.png
  1137. httpx://httpServer@example.org/api?p1=a&p2=b]]>
  1138. </example>
  1139. <p>
  1140. By creating a new scheme for HTTP over XMPP transport, and implementing support for it in web browsers, XML HTTP request objects and web servers,
  1141. Web Applications previously requiring web hosting on the Internet will be able to be seamlessly hosted privately and securely behind firewalls instead,
  1142. by simply switching from the http URL scheme to the httpx URL scheme in the calling application. All relative URL's within the application, including
  1143. URL's sent to the XHR object (Ajax) will automatically be directed to use the HTTP over XMPP transport instead.
  1144. </p>
  1145. </section4>
  1146. <section4 topic='Friendship requests'>
  1147. <p>
  1148. It's beyond the scope of this specification to define how browsers handles its own XMPP account(s) and roster. This section only
  1149. makes a suggestion to show how this can be handled. It is assumed in this discussion that the browser has a working XMPP
  1150. connection with a server, and has its own JID. For simplicity, we will assume the browser has only one connection. Extension to
  1151. multiple connection is canonical.
  1152. </p>
  1153. <p>
  1154. When resolving an URL using the httpx scheme, the browser needs to extract the JID of the server hosting the resource. If that JID
  1155. is already in the roster, the request can proceed as usual.
  1156. </p>
  1157. <p>
  1158. If not in the roster, the browser needs to send a friendship request. A non-exhaustive list of states could be made:
  1159. </p>
  1160. <ul>
  1161. <li>No response: This could be presented as a connection to the content server being made.</li>
  1162. <li>Request rejected: This could be handled in the same way as HTTP Error Forbidden.</li>
  1163. <li>Request accepted: Connection made, proceed with fetching content.</li>
  1164. <li>Timeout: If no friendship request response have been returned, the browser can choose to time out.</li>
  1165. </ul>
  1166. <p>
  1167. Since XMPP works both ways, the browser can receive friendship requests from the outside world. Any such requests should be displayed to the
  1168. end user, if any, or rejected.
  1169. </p>
  1170. <p>
  1171. For more information, see <link url='#rosterclient'>Roster Handling in web clients</link> and
  1172. <link url='#rosterserver'>Roster Handling in web servers</link>.
  1173. </p>
  1174. </section4>
  1175. <section4 topic='Seamless use of web applications hosted at home'>
  1176. <p>
  1177. Today, most people who want to host their own web applications (HTML/HTTP based applications) need to host them on a server publicly
  1178. available on the Internet. However, many applications of a private nature like a family blog, home automation system, etc., is not
  1179. suited for public hosting, since it puts all private data at risk of being compromised, or access to home security functions (like
  1180. home web cams) to get in the hands of people you don't want to have access to them.
  1181. </p>
  1182. <p>
  1183. To solve this, one can host the application on a server at home, perhaps a small cheap plug computer consuming as little as 1 or 2 Watts
  1184. of electricity, using a web server supporting this extension. If the following design rules are followed, the application should be visible
  1185. in any browser also supporting this extensions, as long as friendship exists between the browser and the web server:
  1186. </p>
  1187. <ul>
  1188. <li>
  1189. <p>
  1190. Only relative URL's are used within references (images, audio, video, links, objects, etc.). If absolute URL's are used (including scheme),
  1191. the browser might get the first page correctly, but will be unable to get the content with the absolute URL, unless the URL has the same scheme
  1192. as the principal page.
  1193. </p>
  1194. </li>
  1195. <li>
  1196. <p>
  1197. URL's to web forms must also be relative, for the same reason.
  1198. </p>
  1199. </li>
  1200. <li>
  1201. <p>
  1202. Any URL's sent to the XML HTTP Request (XHR) Object directed to API's or resources hosted by the same application must also be relative,
  1203. for the same reasons as above. The XHR Object supports relative URL's.
  1204. </p>
  1205. </li>
  1206. </ul>
  1207. <p>
  1208. If the above rules are met, which they should under normal conditions, typing in the httpx URL in the browser (for instance when
  1209. you're at the office) should display the application (hosted for example at home behind a firewall) in the same way as when you use http
  1210. (or https) when you have access to the server (for instance when you're home), as long as friendship exists between the browser JID and
  1211. the server JID.
  1212. </p>
  1213. </section4>
  1214. </section3>
  1215. <section3 topic='Web Services'>
  1216. <p>
  1217. Many applications use a Service Oriented Architecture (SOA) and use web services to communicate between clients and servers. These web services
  1218. are mostly HTTP over TCP based, even though there are bindings which are not based on this. The most common APIs today (REST) are however all
  1219. based on HTTP over TCP. Being HTTP over TCP requires the web server hosting the web services either to be public or directly accessible by the
  1220. client. But as the services move closer to end users (for instance a Thermostat publishing a REST API for control in your home), problems arise
  1221. when you try to access the web service outside of private network in which the API is available. As explained previously, the use of HTTP over XMPP
  1222. solves this.
  1223. </p>
  1224. <section4 topic='SOAP'>
  1225. <p>
  1226. The following example shows a simple SOAP method call:
  1227. </p>
  1228. <example caption='SOAP method call'>
  1229. <![CDATA[
  1230. <iq type='set'
  1231. from='httpclient@example.org/browser'
  1232. to='httpserver@example.com'
  1233. id='15'>
  1234. <req xmlns='urn:xmpp:http' method='POST' resource='/Math' version='1.1'>
  1235. <headers xmlns='http://jabber.org/protocol/shim'>
  1236. <header name='Host'>www.example.com</header>
  1237. <header name='Content-Type'>application/soap+xml; charset=utf-8</header>
  1238. <header name='Content-Length'>...</header>
  1239. </headers>
  1240. <data>
  1241. <xml>
  1242. <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
  1243. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  1244. <soap:Body xmlns:m="http://www.example.org/math">
  1245. <m:AddNumbers>
  1246. <m:N1>10</m:N1>
  1247. <m:N2>20</m:N2>
  1248. </m:GetStockPrice>
  1249. </soap:Body>
  1250. </soap:Envelope>
  1251. </xml>
  1252. </data>
  1253. </req>
  1254. </iq>
  1255. <iq type='result'
  1256. from='httpserver@example.com'
  1257. to='httpclient@example.org/browser'
  1258. id='15'>
  1259. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  1260. <headers xmlns='http://jabber.org/protocol/shim'>
  1261. <header name='Content-Type'>application/soap+xml; charset=utf-8</header>
  1262. <header name='Content-Length'>...</header>
  1263. </headers>
  1264. <data>
  1265. <xml>
  1266. <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
  1267. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  1268. <soap:Body xmlns:m="http://www.example.org/math">
  1269. <m:AddNumbersResponse>
  1270. <m:Sum>30</m:Sum>
  1271. </m:AddNumbersResponse>
  1272. </soap:Body>
  1273. </soap:Envelope>
  1274. </xml>
  1275. </data>
  1276. </resp>
  1277. </iq>]]>
  1278. </example>
  1279. <p>
  1280. <strong>Note:</strong> Other components of SOAP, such as WSDL and disco-documents are just examples of content
  1281. handled by simple <link url='#GET'>GET</link> requests.
  1282. </p>
  1283. </section4>
  1284. <section4 topic='REST'>
  1285. <p>
  1286. This section shows an example of a REST method call. REST method calls are just simple <link url='#GET'>GET</link>,
  1287. <link url='#POST'>POST</link>, <link url='#PUT'>PUT</link> or <link url='#DELETE'>DELETE</link> HTTP calls with
  1288. dynamically generated content.
  1289. </p>
  1290. <example caption='REST'>
  1291. <![CDATA[
  1292. <iq type='set'
  1293. from='httpclient@example.org/browser'
  1294. to='httpserver@example.org'
  1295. id='16'>
  1296. <req xmlns='urn:xmpp:http' method='GET' resource='/api/multiplicationtable?m=5' version='1.1'>
  1297. <headers xmlns='http://jabber.org/protocol/shim'>
  1298. <header name='Host'>example.org</header>
  1299. </headers>
  1300. </req>
  1301. </iq>
  1302. <iq type='result'
  1303. from='httpserver@example.org'
  1304. to='httpclient@example.org/browser'
  1305. id='16'>
  1306. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  1307. <headers xmlns='http://jabber.org/protocol/shim'>
  1308. <header name='Date'>Fri, 05 May 2013 15:01:53GMT-4</header>
  1309. <header name='Server'>Clayster</header>
  1310. <header name='Content-Type'>text/xml</header>
  1311. <header name='Content-Length'>...</header>
  1312. </headers>
  1313. <data>
  1314. <xml>
  1315. <table>
  1316. <value n='1' nTimesM='5'/>
  1317. <value n='2' nTimesM='10'/>
  1318. <value n='3' nTimesM='15'/>
  1319. <value n='4' nTimesM='20'/>
  1320. <value n='5' nTimesM='25'/>
  1321. <value n='6' nTimesM='30'/>
  1322. <value n='7' nTimesM='35'/>
  1323. <value n='8' nTimesM='40'/>
  1324. <value n='9' nTimesM='45'/>
  1325. <value n='10' nTimesM='50'/>
  1326. </table>
  1327. </xml>
  1328. </data>
  1329. </resp>
  1330. </iq>]]>
  1331. </example>
  1332. </section4>
  1333. </section3>
  1334. <section3 topic='Semantic Web &amp; IoT'>
  1335. <p>
  1336. The Semantic Web was originally developed as a way to link data between servers on the Web, and understand it. However, with the advents
  1337. of technologies such as <link url='http://www.w3.org/TR/sparql11-query/'>SPARQL</link>, the Semantic Web has become a way to
  1338. unify API's into a universal form of distributed API to all types of data possible. It also allows for a standardized way to perform
  1339. grid computing, in the sense that queries can be federated and executed in a distributed fashion ("in the grid").
  1340. </p>
  1341. <p>
  1342. For these reasons, and others, semantic web technologies have been moving closer to Internet of Things, and also into the private spheres
  1343. of its end users. Since the semantic web technologies are based on HTTP, they also suffer from the shortcomings of HTTP over TCP, when it
  1344. comes to firewalls and user authentication and authorization. Allowing HTTP transport over XMPP greatly improves the reach of semantic
  1345. technologies beyond "The Internet" while at the same time improving security and controllability of the information.
  1346. </p>
  1347. <p>
  1348. As the semantic web moves closer to Internet of Things and the world of XMPP, it can benefit from work done with relation to the Internet of
  1349. Things, such as &xep0324;, which would give automatic control of who (or what) can communicate with whom (or what).
  1350. </p>
  1351. <section4 topic='Turtle'>
  1352. <p>
  1353. Turtle <note>
  1354. Turtle: Terse RDF Triple Language &lt;<link url='http://www.w3.org/TR/turtle/'>http://www.w3.org/TR/turtle/</link>&gt;
  1355. </note>, is a simple way to represent semantic data. The following example shows Turtle-encoded semantic data being returned
  1356. to the client as a response to a request.
  1357. </p>
  1358. <example caption='Turtle'>
  1359. <![CDATA[
  1360. <iq type='result'
  1361. from='httpserver@example.org'
  1362. to='httpclient@example.org/browser'
  1363. id='2'>
  1364. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  1365. <headers xmlns='http://jabber.org/protocol/shim'>
  1366. <header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
  1367. <header name='Server'>Clayster</header>
  1368. <header name='Content-Type'>text/turtle</header>
  1369. <header name='Content-Length'>...</header>
  1370. <header name='Connection'>Close</header>
  1371. </headers>
  1372. <data>
  1373. <text>@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt;.
  1374. @base &lt;http://example.org/&gt;.
  1375. &lt;xep&gt; dc:title "HTTP over XMPP";
  1376. dc:creator &lt;PeterWaher&gt;;
  1377. dc:publisher &lt;XSF&gt;.</text>
  1378. </data>
  1379. </resp>
  1380. </iq>]]>
  1381. </example>
  1382. </section4>
  1383. <section4 topic='RDF'>
  1384. <p>
  1385. RDF <note>
  1386. RDF: Resource Description Framework &lt;<link url='http://www.w3.org/RDF/'>http://www.w3.org/RDF/</link>&gt;
  1387. </note>, is a another way to represent semantic data, better suited than Turtle for M2M communication. Related technologies,
  1388. such as the micro format RDFa <note>
  1389. RDFa: RDF through attributes &lt;<link url='http://www.w3.org/TR/rdfa-syntax/'>http://www.w3.org/TR/rdfa-syntax/</link>&gt;
  1390. </note> allows for embedding RDF into HTML pages or XML documents. The following example shows RDF-encoded semantic data being returned
  1391. to the client as a response to a request.
  1392. </p>
  1393. <example caption='RDF'>
  1394. <![CDATA[
  1395. <iq type='result'
  1396. from='httpserver@example.org'
  1397. to='httpclient@example.org/browser'
  1398. id='17'>
  1399. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  1400. <headers xmlns='http://jabber.org/protocol/shim'>
  1401. <header name='Date'>Fri, 05 May 2013 16:02:23GMT-4</header>
  1402. <header name='Server'>Clayster</header>
  1403. <header name='Content-Type'>application/rdf+xml</header>
  1404. <header name='Content-Length'>...</header>
  1405. </headers>
  1406. <data>
  1407. <xml>
  1408. <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
  1409. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  1410. <rdf:Description rdf:about="http://example.org/xep">
  1411. <dc:title>HTTP over XMPP</dc:title>
  1412. <dc:creator rdf:resource="http://example.org/PeterWaher" />
  1413. <dc:publisher rdf:resource="http://example.org/XSF" />
  1414. </rdf:Description>
  1415. </rdf:RDF>
  1416. </xml>
  1417. </data>
  1418. </resp>
  1419. </iq>]]>
  1420. </example>
  1421. </section4>
  1422. <section4 topic='SPARQL'>
  1423. <p>
  1424. This section shows an example of a SPARQL query executed as a POST call.
  1425. </p>
  1426. <example caption='SPARQL'>
  1427. <![CDATA[
  1428. <iq type='set'
  1429. from='httpclient@example.org/browser'
  1430. to='httpserver@example.org'
  1431. id='4'>
  1432. <req xmlns='urn:xmpp:http' method='POST' version='1.1'
  1433. resource='/sparql/?default-graph-uri=http%3A%2F%2Fanother.example%2Fcalendar.rdf'>
  1434. <headers xmlns='http://jabber.org/protocol/shim'>
  1435. <header name='Host'>example.org</header>
  1436. <header name='User-agent'>Clayster HTTP/XMPP Client</header>
  1437. <header name='Content-Type'>application/sparql-query</header>
  1438. <header name='Content-Length'>...</header>
  1439. </headers>
  1440. <data>
  1441. <text>@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt;.
  1442. @base &lt;http://example.org/&gt;.
  1443. &lt;xep&gt; dc:title "HTTP over XMPP";
  1444. dc:creator &lt;PeterWaher&gt;;
  1445. dc:publisher &lt;XSF&gt;.</text>
  1446. </data>
  1447. </req>
  1448. </iq>
  1449. <iq type='result'
  1450. from='httpserver@example.org'
  1451. to='httpclient@example.org/browser'
  1452. id='4'>
  1453. <resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
  1454. <headers xmlns='http://jabber.org/protocol/shim'>
  1455. <header name='Date'>Fri, 03 May 2013 17:09:34-4</header>
  1456. <header name='Server'>Clayster</header>
  1457. <header name='Content-Type'>application/sparql-results+xml</header>
  1458. <header name='Content-Length'>...</header>
  1459. </headers>
  1460. <data>
  1461. <xml>
  1462. <sparql xmlns="http://www.w3.org/2005/sparql-results#">
  1463. <head>
  1464. <variable name="title"/>
  1465. <variable name="creator"/>
  1466. </head>
  1467. <results>
  1468. <result>
  1469. <binding name="title">
  1470. <literal>HTTP over XMPP</literal>
  1471. </binding>
  1472. <binding name="creator">
  1473. <uri>http://example.org/PeterWaher</uri>
  1474. </binding>
  1475. </result>
  1476. </results>
  1477. </sparql>
  1478. </xml>
  1479. </data>
  1480. </resp>
  1481. </iq>]]>
  1482. </example>
  1483. </section4>
  1484. </section3>
  1485. <section3 topic='Streaming'>
  1486. <p>
  1487. There are many types of streams and streaming protocols. Several of these are based on HTTP or variants simulating HTTP. Examples of such HTTP-based or
  1488. pseudo-HTTP based streaming protocols can include HLS <note>
  1489. HLS: HTTP Live Streaming &lt;<link url='http://en.wikipedia.org/wiki/HTTP_Live_Streaming'>http://en.wikipedia.org/wiki/HTTP_Live_Streaming</link>&gt;
  1490. </note> used for multi-media streaming,
  1491. SHOUTcast <note>
  1492. SHOUTcast &lt;<link url='http://en.wikipedia.org/wiki/SHOUTcast'>http://en.wikipedia.org/wiki/SHOUTcast</link>&gt;
  1493. </note> used for internet radio and
  1494. Motion JPeg <note>
  1495. Motion JPeg &lt;<link url='http://en.wikipedia.org/wiki/Motion_JPEG'>http://en.wikipedia.org/wiki/Motion_JPEG</link>&gt;
  1496. </note> common format for web cameras.
  1497. </p>
  1498. <p>
  1499. Common for all streaming data, is that they are indefinite, but at the same time rate-limited depending on quality, etc. Because of this, the
  1500. web server is required to use the <link url='#streams'>ibb</link> encoding or the <link url='#jingle'>jingle</link> encoding to
  1501. transport the content to the client.
  1502. </p>
  1503. </section3>
  1504. </section2>
  1505. </section1>
  1506. <section1 topic='Determining Support' anchor='support'>
  1507. <p>If an entity supports the protocol specified herein, it MUST advertise that fact by returning a feature of "urn:xmpp:http" in response to &xep0030; information requests.</p>
  1508. <example caption="Service discovery information request">
  1509. <![CDATA[
  1510. <iq type='set'
  1511. from='httpclient@example.org/browser'
  1512. to='httpserver@example.org'
  1513. id='disco1'>
  1514. <query xmlns='http://jabber.org/protocol/disco#info'/>
  1515. </iq>]]>
  1516. </example>
  1517. <example caption="Service discovery information response">
  1518. <![CDATA[
  1519. <iq type='result'
  1520. from='httpserver@example.org'
  1521. to='httpclient@example.org/browser'
  1522. id='disco1'>
  1523. <query xmlns='http://jabber.org/protocol/disco#info'>
  1524. ...
  1525. <feature var='urn:xmpp:http'/>
  1526. ...
  1527. </query>
  1528. </iq>]]>
  1529. </example>
  1530. <p>
  1531. In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined
  1532. in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.
  1533. </p>
  1534. </section1>
  1535. <section1 topic='Implementation Notes' anchor='impl'>
  1536. <section2 topic='Connection handling' anchor='httpconnections'>
  1537. <p>
  1538. HTTP over TCP includes headers for connection handling. The basic sequence for an HTTP request might be:
  1539. </p>
  1540. <ul>
  1541. <li>Client connects to server</li>
  1542. <li>Clients sends request</li>
  1543. <li>Client received response</li>
  1544. <li>Client closes connection</li>
  1545. </ul>
  1546. <p>
  1547. However, in the HTTP over XMPP case, there are no connections between the client and the server. Both clients and servers
  1548. have active connections to the XMPP Server, but these remain unchanged during the sequence of requests. Therefore, both
  1549. clients and servers should ignore any HTTP over TCP connection settings, since they have no meaning in the HTTP over XMPP
  1550. case. However, the corresponding headers should always be transported as is, to maintain the information.
  1551. </p>
  1552. </section2>
  1553. <section2 topic='HTTP Headers' anchor='headers'>
  1554. <p>
  1555. HTTP Headers are serialized to and from XML using the XEP-0131 <link url='http://xmpp.org/extensions/xep-0131.html'>Stanza Headers and Internet Metadata</link>.
  1556. However, this does not mean that the SHIM feature needs to be published by the client, as defined in §3 in
  1557. <link url='http://xmpp.org/extensions/xep-0131.html#disco'>XEP-0131</link>, since the headers will be embedded into the HTTP elements.
  1558. Also, if there is any conflicts in how to store header values, when it comes to data types, etc., the original format as used by the original
  1559. HTTP request must be used, and not the format defined in <link url='http://xmpp.org/extensions/xep-0131.html#headers'>Header Definitions</link> or
  1560. <link url='http://xmpp.org/extensions/xep-0131.html#dates'>A Note About date-Related Headers</link> in XEP-0131.
  1561. </p>
  1562. <p>
  1563. The HTTP over XMPP tunnel is just a tunnel of HTTP over XMPP, it does not know the semantic meaning of headers used in the transport. It does not know
  1564. if additional headers added by the myriad of custom applications using HTTP are actually HTTP-compliant. It just acts as a transport, returning the
  1565. sime kind of response (being deterministric) as if the original request was made through other means, for example over TCP. It does not add, remove or
  1566. change semantic meaning of keys and values, nor change the format of the corresponding values. Such changes will create uncountable problems very difficult
  1567. to detect and solve in a general case.
  1568. </p>
  1569. <p>
  1570. This specification differs from XEP-0131 in that this specification the headers are consumed by web servers and web clients (The XMPP client here only
  1571. being a "dumb" gateway), while in XEP-0131 the headers are consumed by the XMPP clients themselves, knowing XML and XML formats.
  1572. </p>
  1573. </section2>
  1574. <section2 topic='Stanza Sizes'>
  1575. <p>
  1576. Some XMPP Servers may limit stanza sizes for various reasons. While this may work well for certain applications, like
  1577. Instant Messaging and Chat, implementors of HTTP over XMPP need to know that some server have such stanza size
  1578. restrictions. Therefore, an implementation should include configurable size limits, so chunking can be used instead
  1579. of sending large stanzas. Another limit could be when streaming should be used instead of chunking. This later limit
  1580. should be applied in particular on audio and video content.
  1581. </p>
  1582. <p>
  1583. The implementor should also consider to send large content in the form of files using file transfer, and large multi-media
  1584. content using Jingle.
  1585. </p>
  1586. <p>
  1587. <strong>Note:</strong> According to &rfc6120; there is a smallest allowed maximum stanza size that all XMPP servers must support.
  1588. According to §13.12.4 of that document, this limit is set to 10000 bytes including all characters from the opening &lt; character
  1589. to the closing &gt; character.
  1590. </p>
  1591. </section2>
  1592. <section2 topic='Bandwidth Limitations'>
  1593. <p>
  1594. Some XMPP Servers may also have bandwidth resitrctions enforced. This to limit the possibility of Denial of Service attacks
  1595. or similar flooding of messages. Implementors of the HTTP over XMPP extensions must know however, that the bandwidth
  1596. limitations for instant messaging and chat may be completely different from that of normal web applications. In chatting,
  1597. a 1000 bytes/s limit is in most cases sufficient, while the same limit for even a modest web applications will make the
  1598. application completely impossible to use.
  1599. </p>
  1600. </section2>
  1601. </section1>
  1602. <section1 topic='Security Considerations' anchor='security'>
  1603. <p>
  1604. It's beyond the scope of this document to define how HTTP clients or HTTP servers handle rosters internally. The following
  1605. sections list suggestions on how these can be handled by different parties.
  1606. </p>
  1607. <section2 topic='Roster handling in browsers' anchor='rosterclient'>
  1608. <p>
  1609. Since browsers are operated by end users, any friendship request received from the outside should be either shown to the user
  1610. (if the browser also maintains an IM client), or automatically rejected.
  1611. </p>
  1612. <p>
  1613. On the other hand, when the browser wants to access an URL using the httpx scheme, an automatic friendship request to the
  1614. corresponding JID should be done, if not already in the roster. It is assumed that by entering the URL, or using the URL
  1615. of an application already displayed, this implies giving permission to add that JID as a friend to the roster of the
  1616. browser.
  1617. </p>
  1618. </section2>
  1619. <section2 topic='Roster handling in web servers' anchor='rosterserver'>
  1620. <p>
  1621. A web server should have different security settings available. The following subsections list possible settings for different
  1622. scenarios. Note that these settings only reflect roster handling and cannot be set per resource. However, the server can
  1623. maintain a set of JIDs with different settings and restrict access to parts of the content hosted by the server per JID.
  1624. </p>
  1625. <section3 topic='Public Server'>
  1626. <p>
  1627. A public server should accept requests from anybody (reachable from the current JID). All friendship requests should be
  1628. automatically accepted.
  1629. </p>
  1630. <p>
  1631. To avoid bloating the roster, friendship requests could be automatically unsubscribed once the HTTP session has ended.
  1632. </p>
  1633. </section3>
  1634. <section3 topic='Manual Server'>
  1635. <p>
  1636. All new friendship are shown (or queued) to an administrator for manual acceptance or rejection. Once accepted, the client
  1637. can access the corresponding content. During the wait (which can be substantial), the client should display a message
  1638. that the friendship request is sent and response is pending.
  1639. </p>
  1640. <p>
  1641. Automatic unsubscription of friendships should only be done on a much longer inactivity timeframe than the normal session
  1642. timeout interval.
  1643. </p>
  1644. </section3>
  1645. <section3 topic='Private Server'>
  1646. <p>
  1647. All new friendship requests are automatically rejected. Only already accepted friendships are allowed to make HTTP requests
  1648. to the server.
  1649. </p>
  1650. </section3>
  1651. <section3 topic='Provisioned Server'>
  1652. <p>
  1653. All new friendship requests are delegated to a trusted third party, according to
  1654. <link url='http://xmpp.org/extensions/xep-0324.html'>XEP 0324: Internet of Things - Provisioning</link>. Friendship
  1655. acceptance or rejection is then performed according to the response from the provisioning server(s).
  1656. </p>
  1657. <p>
  1658. Automatic friendship unsubscription can be made to avoid bloating the roster. However, the time interval for unsubscribing
  1659. inactive users should be longer than the normal session timeout period, to avoid spamming any provisioning servers each
  1660. time a client requests friendship.
  1661. </p>
  1662. </section3>
  1663. </section2>
  1664. </section1>
  1665. <section1 topic='IANA Considerations' anchor='iana'>
  1666. <p>
  1667. The httpx URL scheme, as described <link url='#httpxscheme'>above</link>, must be registered as a provisional URI scheme according to BCP 35 <note>
  1668. BCP 35: New URI Schemes &lt;<link url='http://tools.ietf.org/html/bcp35'>http://tools.ietf.org/html/bcp35</link>&gt;
  1669. </note>. The registration procedure is specified in <link url='http://tools.ietf.org/html/bcp35#section-7'>BCP 35, section 7</link>.
  1670. </p>
  1671. <section2 topic='URI Scheme Registration Template'>
  1672. <p>
  1673. Following is an URI Scheme Registration Template, as per <link url='http://tools.ietf.org/html/bcp35#section-7.4'>BCP 35, section 7.4</link>.
  1674. </p>
  1675. <dl>
  1676. <di>
  1677. <dt>URI scheme name</dt>
  1678. <dd>
  1679. <p>
  1680. httpx
  1681. </p>
  1682. </dd>
  1683. </di>
  1684. <di>
  1685. <dt>Status</dt>
  1686. <dd>
  1687. <p>
  1688. provisional
  1689. </p>
  1690. </dd>
  1691. </di>
  1692. <di>
  1693. <dt>URI scheme syntax</dt>
  1694. <dd>
  1695. <p>
  1696. The syntax used for the httpx scheme reuses the URI scheme syntax for the http scheme, as defined in RFC 2616:
  1697. </p>
  1698. <code>
  1699. <![CDATA[
  1700. http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]]]>
  1701. </code>
  1702. <p>
  1703. Instead of using host and port to define the where the HTTP server resides, the httpx scheme uses a resource-less
  1704. XMPP JID to define where the HTTP server resides, implying the use of HTTP over XMPP as defined in this document
  1705. instead of HTTP over TCP:
  1706. </p>
  1707. <code>
  1708. <![CDATA[
  1709. httpx_URL = "httpx:" "//" resourceless_jid [ abs_path [ "?" query ]]]]>
  1710. </code>
  1711. <p>
  1712. Here, the host and port parts of normal HTTP URLs have been replaced by the resource-less JID of the HTTP Server, i.e. only the user name,
  1713. the @ character and the domain. The / separator between the resource-less JID and the following abs_path, is part of abs_path.
  1714. </p>
  1715. <code>
  1716. <![CDATA[
  1717. httpx://httpServer@example.org/index.html
  1718. httpx://httpServer@example.org/images/image1.png
  1719. httpx://httpServer@example.org/api?p1=a&p2=b]]>
  1720. </code>
  1721. </dd>
  1722. </di>
  1723. <di>
  1724. <dt>URI scheme semantics</dt>
  1725. <dd>
  1726. <p>
  1727. By creating a new scheme for HTTP over XMPP transport, and implementing support for it in web browsers, XML HTTP request objects and web servers,
  1728. Web Applications previously requiring web hosting on the Internet will be able to be seamlessly hosted privately and securely behind firewalls instead,
  1729. by simply switching from the http URL scheme to the httpx URL scheme in the calling application. All relative URL's within the application, including
  1730. URL's sent to the XHR object (Ajax) will automatically be directed to use the HTTP over XMPP transport instead.
  1731. </p>
  1732. </dd>
  1733. </di>
  1734. <di>
  1735. <dt>Encoding considerations</dt>
  1736. <dd>
  1737. <p>
  1738. Encoding is fully described in the
  1739. <link url='http://xmpp.org/extensions/xep-0332.html#encoding'>Encoding section of the HTTP over XMPP XEP</link> document.
  1740. </p>
  1741. </dd>
  1742. </di>
  1743. <di>
  1744. <dt>Applications/protocols that use this URI scheme name</dt>
  1745. <dd>
  1746. <p>
  1747. This URI scheme is to be used in the same environments and by the same types of applications as the http URI scheme.
  1748. </p>
  1749. </dd>
  1750. </di>
  1751. <di>
  1752. <dt>Interoperability considerations</dt>
  1753. <dd>
  1754. <p>
  1755. Interoperability considerations is described in the
  1756. <link url='http://xmpp.org/extensions/xep-0332.html#impl'>Implementation Notes section of the HTTP over XMPP XEP</link> document.
  1757. </p>
  1758. </dd>
  1759. </di>
  1760. <di>
  1761. <dt>Security considerations</dt>
  1762. <dd>
  1763. <p>
  1764. Security considerations is described in the
  1765. <link url='http://xmpp.org/extensions/xep-0332.html#security'>Security considerations section of the HTTP over XMPP XEP</link> document.
  1766. </p>
  1767. </dd>
  1768. </di>
  1769. <di>
  1770. <dt>Contact</dt>
  1771. <dd>
  1772. <p>
  1773. For further information, please contact Peter Waher:
  1774. </p>
  1775. <p>
  1776. Email: <link url='mailto:peter.waher@example.org'>peter.waher@example.org</link><br/>
  1777. JabberID: <link url='xmpp:peter.waher@jabber.org'>peter.waher@jabber.org</link><br/>
  1778. URI: <link url='http://www.linkedin.com/in/peterwaher'>http://www.linkedin.com/in/peterwaher</link>
  1779. </p>
  1780. </dd>
  1781. </di>
  1782. <di>
  1783. <dt>Author/Change controller</dt>
  1784. <dd>
  1785. <p>
  1786. For concerns regarding changes to the provisional registration, please contact Peter Waher:
  1787. </p>
  1788. <p>
  1789. Email: <link url='mailto:peter.waher@example.org'>peter.waher@example.org</link><br/>
  1790. JabberID: <link url='xmpp:peter.waher@jabber.org'>peter.waher@jabber.org</link><br/>
  1791. URI: <link url='http://www.linkedin.com/in/peterwaher'>http://www.linkedin.com/in/peterwaher</link>
  1792. </p>
  1793. </dd>
  1794. </di>
  1795. <di>
  1796. <dt>References</dt>
  1797. <dd>
  1798. <p>
  1799. Following is a short list of referenced documents:
  1800. </p>
  1801. <ol>
  1802. <li>
  1803. RFC 6120: <link url='http://tools.ietf.org/html/rfc6120'>
  1804. Extensible Messaging and Presence Protocol (XMPP): Core
  1805. </link>
  1806. </li>
  1807. <li>
  1808. RFC 2616: <link url='http://tools.ietf.org/html/rfc2616'>
  1809. Hypertext Transfer Protocol -- HTTP/1.1
  1810. </link>
  1811. </li>
  1812. <li>
  1813. HTTP over XMPP XEP: <link url='http://xmpp.org/extensions/xep-0332.html'>
  1814. XMPP Extension Protocol: HTTP over XMPP
  1815. </link>
  1816. </li>
  1817. </ol>
  1818. </dd>
  1819. </di>
  1820. </dl>
  1821. </section2>
  1822. </section1>
  1823. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  1824. <p>
  1825. The <link url="#schema">protocol schema</link> needs to be added to the list of <link url="http://xmpp.org/resources/schemas/">XMPP protocol schemas</link>.
  1826. </p>
  1827. </section1>
  1828. <section1 topic='XML Schema' anchor='schema'>
  1829. <code>
  1830. <![CDATA[
  1831. <?xml version='1.0' encoding='UTF-8'?>
  1832. <xs:schema
  1833. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  1834. targetNamespace='urn:xmpp:http'
  1835. xmlns='urn:xmpp:http'
  1836. xmlns:shim='http://jabber.org/protocol/shim'
  1837. xmlns:sipub='http://jabber.org/protocol/sipub'
  1838. xmlns:ibb='http://jabber.org/protocol/ibb'
  1839. xmlns:jingle='urn:xmpp:jingle:1'
  1840. elementFormDefault='qualified'>
  1841. <xs:import namespace='http://jabber.org/protocol/shim'/>
  1842. <xs:import namespace='http://jabber.org/protocol/sipub'/>
  1843. <xs:import namespace='http://jabber.org/protocol/ibb'/>
  1844. <xs:import namespace='urn:xmpp:jingle:1'/>
  1845. <xs:element name='req'>
  1846. <xs:complexType>
  1847. <xs:sequence>
  1848. <xs:element ref='shim:headers' minOccurs='0' maxOccurs='1'/>
  1849. <xs:element name='data' type='Data' minOccurs='0' maxOccurs='1'/>
  1850. </xs:sequence>
  1851. <xs:attribute name='method' type='Method' use='required'/>
  1852. <xs:attribute name='resource' type='xs:string' use='required'/>
  1853. <xs:attribute name='version' type='Version' use='required'/>
  1854. <xs:attribute name='maxChunkSize' type='MaxChunkSize' use='optional'/>
  1855. <xs:attribute name='sipub' type='xs:boolean' use='optional' default='true'/>
  1856. <xs:attribute name='ibb' type='xs:boolean' use='optional' default='true'/>
  1857. <xs:attribute name='jingle' type='xs:boolean' use='optional' default='true'/>
  1858. </xs:complexType>
  1859. </xs:element>
  1860. <xs:simpleType name='MaxChunkSize'>
  1861. <xs:restriction base='xs:int'>
  1862. <xs:minInclusive value='256'/>
  1863. <xs:maxInclusive value='65536'/>
  1864. </xs:restriction>
  1865. </xs:simpleType>
  1866. <xs:element name='resp'>
  1867. <xs:complexType>
  1868. <xs:sequence>
  1869. <xs:element ref='shim:headers' minOccurs='0' maxOccurs='1'/>
  1870. <xs:element name='data' type='Data' minOccurs='0' maxOccurs='1'/>
  1871. </xs:sequence>
  1872. <xs:attribute name='version' type='Version' use='required'/>
  1873. <xs:attribute name='statusCode' type='xs:positiveInteger' use='required'/>
  1874. <xs:attribute name='statusMessage' type='xs:string' use='optional'/>
  1875. </xs:complexType>
  1876. </xs:element>
  1877. <xs:complexType name='Data'>
  1878. <xs:choice minOccurs='1' maxOccurs='1'>
  1879. <xs:element name='text' type='xs:string'>
  1880. <xs:annotation>
  1881. <xs:documentation>Used for text responses that are not XML.</xs:documentation>
  1882. </xs:annotation>
  1883. </xs:element>
  1884. <xs:element name='xml'>
  1885. <xs:annotation>
  1886. <xs:documentation>Specifically used for XML-formatted responses.</xs:documentation>
  1887. </xs:annotation>
  1888. <xs:complexType>
  1889. <xs:sequence minOccurs='0' maxOccurs='1'>
  1890. <xs:any processContents="lax" namespace="##any"/>
  1891. </xs:sequence>
  1892. </xs:complexType>
  1893. </xs:element>
  1894. <xs:element name="base64" type="xs:base64Binary">
  1895. <xs:annotation>
  1896. <xs:documentation>Short binary responses, base-64 encoded.</xs:documentation>
  1897. </xs:annotation>
  1898. </xs:element>
  1899. <xs:element name="chunkedBase64">
  1900. <xs:annotation>
  1901. <xs:documentation>Content is divided into chunks of binary base-64 encoded data.</xs:documentation>
  1902. <xs:documentation>Used if content is generated dynamically and/or content size is not known.</xs:documentation>
  1903. <xs:documentation>For streaming data the ibb:open or jingle:jingle transports must be used.</xs:documentation>
  1904. <xs:documentation>For static data, such as files, sipub:sipub should be used.</xs:documentation>
  1905. </xs:annotation>
  1906. <xs:complexType>
  1907. <xs:attribute name="streamId" type="xs:string" use="required"/>
  1908. </xs:complexType>
  1909. </xs:element>
  1910. <xs:element ref='sipub:sipub'>
  1911. <xs:annotation>
  1912. <xs:documentation>Content available through file transfer.</xs:documentation>
  1913. </xs:annotation>
  1914. </xs:element>
  1915. <xs:element name="ibb">
  1916. <xs:annotation>
  1917. <xs:documentation>Content returned through an in-band bytestream.</xs:documentation>
  1918. </xs:annotation>
  1919. <xs:complexType>
  1920. <xs:attribute name="sid" type="xs:string" use="required"/>
  1921. </xs:complexType>
  1922. </xs:element>
  1923. <xs:element ref="jingle:jingle">
  1924. <xs:annotation>
  1925. <xs:documentation>Multi-media content returned through jingle.</xs:documentation>
  1926. </xs:annotation>
  1927. </xs:element>
  1928. </xs:choice>
  1929. </xs:complexType>
  1930. <xs:element name="chunk">
  1931. <xs:complexType>
  1932. <xs:simpleContent>
  1933. <xs:extension base="xs:base64Binary">
  1934. <xs:attribute name="streamId" type="xs:string" use="required"/>
  1935. <xs:attribute name="nr" type="xs:nonNegativeInteger" use="required"/>
  1936. <xs:attribute name="last" type="xs:boolean" use="optional" default="false"/>
  1937. </xs:extension>
  1938. </xs:simpleContent>
  1939. </xs:complexType>
  1940. </xs:element>
  1941. <xs:element name='close'>
  1942. <xs:complexType>
  1943. <xs:attribute name='streamId' type='xs:string' use='required'/>
  1944. </xs:complexType>
  1945. </xs:element>
  1946. <xs:simpleType name='Method'>
  1947. <xs:restriction base='xs:string'>
  1948. <xs:enumeration value='OPTIONS'/>
  1949. <xs:enumeration value='GET'/>
  1950. <xs:enumeration value='HEAD'/>
  1951. <xs:enumeration value='POST'/>
  1952. <xs:enumeration value='PUT'/>
  1953. <xs:enumeration value='DELETE'/>
  1954. <xs:enumeration value='TRACE'/>
  1955. <xs:enumeration value='PATCH'/>
  1956. </xs:restriction>
  1957. </xs:simpleType>
  1958. <xs:simpleType name='Version'>
  1959. <xs:restriction base='xs:string'>
  1960. <xs:pattern value='\d[.]\d'/>
  1961. </xs:restriction>
  1962. </xs:simpleType>
  1963. </xs:schema>]]>
  1964. </code>
  1965. </section1>
  1966. <section1 topic='Acknowledgements' anchor='ack'>
  1967. <p>Thanks to Peter Saint-Andre, Karin Forsell, Matthew A. Miller, Kevin Smith and Ralph Meijer for all valuable feedback.</p>
  1968. </section1>
  1969. </xep>