HTTP-response.xhtml 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
  3. <head>
  4. <title>Generating HTTP responses</title>
  5. <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
  6. <link rel="stylesheet" type="text/css" href="kawa.css"/>
  7. <script src="kawa-ebook.js" type="text/javascript"/>
  8. <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
  9. <link rel="prev" href="HTTP-requests.xhtml" title="Functions for accessing HTTP requests"/>
  10. <link rel="next" href="XML-beyond-Scheme.xhtml" title="Using non-Scheme languages for XML/HTML"/>
  11. </head>
  12. <body>
  13. <header/>
  14. <section class="sect1" title="Generating HTTP responses" epub:type="subchapter" id="HTTP-response">
  15. <div class="titlepage">
  16. <div>
  17. <div>
  18. <h2 class="title" style="clear: both">Generating HTTP responses</h2>
  19. </div>
  20. </div>
  21. </div>
  22. <p>The result of evaluating the top-level expressions of a web page script
  23. becomes the HTTP response that the servlet sends back to the browser.
  24. The result is typically an HTML/XML element code object
  25. Kawa will automatically format the result as appropriate for the type.
  26. Before the main part of the response there may be
  27. special "response header values",
  28. as created by the <code class="literal">response-header</code> function.
  29. Kawa will use the response header values to set various
  30. required and optional fields of the HTTP response.
  31. Note that <code class="literal">response-header</code> does not actually do anything
  32. until it is "printed" to the standard output.
  33. Note also that a <code class="literal">"Content-Type"</code> response value is
  34. special since it controls the formatting of the following
  35. non-response-header values.
  36. </p>
  37. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667870150448" class="indexterm"/> <code class="function">response-header</code> <em class="replaceable"><code>key</code></em> <em class="replaceable"><code>value</code></em></p>
  38. <div class="blockquote">
  39. <blockquote class="blockquote">
  40. <p>Create the response header ‘<code class="literal"><em class="replaceable"><code>key</code></em>: <em class="replaceable"><code>value</code></em></code>’ in the HTTP
  41. response. The result is a "response header value" (of some unspecified
  42. type). It does not directly set or print a response header, but only
  43. does so when you actually "print" its value to the response output stream.
  44. </p>
  45. </blockquote>
  46. </div>
  47. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667870145280" class="indexterm"/> <code class="function">response-content-type</code> <em class="replaceable"><code>type</code></em></p>
  48. <div class="blockquote">
  49. <blockquote class="blockquote">
  50. <p>Species the content-type of the result - for example <code class="literal">"text/plain"</code>.
  51. Convenience function for <code class="literal">(response-header "Content-Type" <em class="replaceable"><code>type</code></em>)</code>.
  52. </p>
  53. </blockquote>
  54. </div>
  55. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667870140560" class="indexterm"/> <code class="function">error-response</code> <em class="replaceable"><code>code</code></em> [<em class="replaceable"><code>message</code></em>]</p>
  56. <div class="blockquote">
  57. <blockquote class="blockquote">
  58. <p>Creates a response-header with an error code of <em class="replaceable"><code>code</code></em> and a
  59. response message of <em class="replaceable"><code>message</code></em>.
  60. (For now this is the same as <code class="literal">response-status</code>.)
  61. </p>
  62. <p>Note this also returns a response-header value, which does not actually
  63. do anything unless it is returned as the result of executing a servlet body.
  64. </p>
  65. </blockquote>
  66. </div>
  67. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667870134720" class="indexterm"/> <code class="function">response-status</code> <em class="replaceable"><code>code</code></em> [<em class="replaceable"><code>message</code></em>]</p>
  68. <div class="blockquote">
  69. <blockquote class="blockquote">
  70. <p>Creates a response-header with an status code of <em class="replaceable"><code>code</code></em> and a
  71. response message of <em class="replaceable"><code>message</code></em>.
  72. (For now this is the same as <code class="literal">error-response</code>.)
  73. </p>
  74. </blockquote>
  75. </div>
  76. </section>
  77. <footer>
  78. <div class="navfooter">
  79. <p>
  80. Up: <a accesskey="u" href="XML-tools.xhtml">Working with XML and HTML</a></p>
  81. <p>
  82. Previous: <a accesskey="p" href="HTTP-requests.xhtml">Functions for accessing HTTP requests</a></p>
  83. <p>
  84. Next: <a accesskey="n" href="XML-beyond-Scheme.xhtml">Using non-Scheme languages for XML/HTML</a></p>
  85. </div>
  86. </footer>
  87. </body>
  88. </html>