From f0dfefa58657853f6d7879f081366443563de5e9 Mon Sep 17 00:00:00 2001
From: Sascha Schulz <sschulz@dh-software.de>
Date: Mi, 05 Apr 2023 15:34:55 +0200
Subject: [PATCH] finish chapter HTTP and add chapter JSON

---
 index.html |  208 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 203 insertions(+), 5 deletions(-)

diff --git a/index.html b/index.html
index b75af3c..8207769 100644
--- a/index.html
+++ b/index.html
@@ -688,14 +688,212 @@
 					</section>
 					<section>
 						<ul>
-							<li>Befindet sich auf den OSI-Schichten 5, 6 und 7</li>
-							<li>Basiert auf dem Anfrage-Antwort-Prinzip</li>
-							<li>Basiert auf reinem Text</li>
+							<li>OSI-Schichten 5, 6 und 7</li>
+							<li>Anfrage-Antwort-Prinzip</li>
+							<li>Basiert auf einfachem Text</li>
 						</ul>
 					</section>
 					<section>
-						<p><code>npm install http-server</code></p>
-						<p><code>npx http-server --port 3000</code></p>
+						<table>
+							<tr><th>Version</th><th>Jahr</th></tr>
+							<tr><th>0.9</th><th>1991</th></tr>
+							<tr><th>1.0</th><th>1996</th></tr>
+							<tr><th>1.1</th><th>1999</th></tr>
+							<tr><th>2.0</th><th>2015</th></tr>
+							<tr><th>3.0</th><th>2022</th></tr>
+						</table>
+					</section>
+					<section>
+						<p>Request an www.google.de</p>
+						<pre>
+							<code class="http" data-trim data-line-numbers>
+								GET / HTTP/1.1
+								Host: www.google.de
+								User-Agent: curl/7.88.1
+								Accept: */*
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p>Response von www.google.de</p>
+						<pre>
+							<code class="http" data-trim data-line-numbers>
+								HTTP/1.1 200 OK
+								Date: Tue, 04 Apr 2023 15:45:26 GMT
+								Expires: -1
+								Cache-Control: private, max-age=0
+								Content-Type: text/html; charset=ISO-8859-1
+								Content-Security-Policy-Report-Only: [...]
+								Server: gws
+								X-XSS-Protection: 0
+								X-Frame-Options: SAMEORIGIN
+								Set-Cookie: [...]
+								Accept-Ranges: none
+								Vary: Accept-Encoding
+								Transfer-Encoding: chunked
+								
+								&lt;!doctype html&gt;&lt;html&gt;...&lt;/html&gt;
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p>Einfach mal testen:</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								curl -v --http1.0 http://www.google.de
+								curl -v --http1.1 http://www.google.de
+								curl -v --http2 http://www.google.de
+								curl -v --http2-prior-knowledge http://www.google.de
+								curl -v --http3 http://www.google.de
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p>Verschiedene "Verben" bzw. "Methoden"</p>
+						<ul>
+							<li>GET</li>
+							<li>POST</li>
+							<li>PUT</li>
+							<li>PATCH</li>
+							<li>DELETE</li>
+							<li>...</li>
+						</ul>
+					</section>
+					<section>
+						<p>Beispiel:</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								git clone https://git.furnco.de/r/public/web-development/examples.git
+								cd examples/templates/005-http-rest
+								node index.js
+							</code>
+						</pre>
+					</section>
+					<section>
+						<pre>
+							<code class="text" data-trim data-line-numbers>
+								curl -X GET -is http://localhost:3000/todo
+								curl -X POST -H "Content-Type: application/json" -d '{"name": "Einkaufen"}' -is http://localhost:3000/todo
+								curl -X POST -H "Content-Type: application/json" -d '{"name": "Putzen"}' -is http://localhost:3000/todo
+								curl -X PUT -H "Content-Type: application/json" -d '{"name": "Schlafen"}' -is http://localhost:3000/todo/1
+								curl -X DELETE -is http://localhost:3000/todo/0
+							</code>
+						</pre>
+					</section>
+					<section>
+						<pre>
+							<code class="text" data-trim data-line-numbers>
+								HTTP/1.1 200 OK
+								X-Powered-By: Express
+								Content-Type: application/json; charset=utf-8
+								Content-Length: 13
+								ETag: W/"d-KMmUcQ1kigqtwzZnU+jVDkYP3Co"
+								Date: Wed, 05 Apr 2023 12:05:05 GMT
+								Connection: keep-alive
+								Keep-Alive: timeout=5
+								
+								["Einkaufen"]
+							</code>
+						</pre>
+					</section>
+					<section>
+						<pre>
+							<code class="js" data-trim data-line-numbers="">
+								app.get("/todo", (req, res) => {
+									return res.json(todos);
+								});
+								
+								// [...]
+								
+								app.post("/todo", (req, res) => {
+									// [...]
+										return res.json(todos);
+									// [...]
+								});
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p><code>GET</code> und <code>POST</code> auf klassischen Webseiten</p>
+						<pre>
+							<code class="html" data-trim data-line-numbers>
+								<form method="post" action="/todo">
+									<input name="todo"><button>add</button>
+								</form>
+							</code>
+						</pre>
+						<p>Beispiel:</p>
+						<pre>
+							<code class="bash" data-trim data-line-numbers>
+								cd examples/templates/006-http-web
+								node index.js
+							</code>
+						</pre>
+					</section>
+				</section>
+				<section>
+					<section>
+						<h3>JSON</h3>
+					</section>
+					<section>
+						<ul>
+							<li><em class="h">J</em>ava<em class="h">S</em>cript <em class="h">O</em>bject <em class="h">N</em>otation</li>
+							<li>Basiert auf reinem Text</li>
+							<li>Format zur strukturierten Speicherung von Daten</li>
+							<li>Attribute müssen immer in doppelte Anführungsstriche (<code>"</code>) gesetzt werden</li>
+						</ul>
+					</section>
+					<section>
+						<p>Definition eines einfachen Objekts in JS</p>
+						<pre>
+							<code class="js" data-trim data-line-numbers>
+								const o = {
+									x: 1,
+									y: 2
+								};
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p>Entsprechung in JSON</p>
+						<pre>
+							<code class="js" data-trim data-line-numbers>
+								{
+									"x": 1,
+									"y": 2
+								}
+							</code>
+						</pre>
+					</section>
+					<section>
+						<p>Mögliche Typen</p>
+						<p>
+							<ul>
+								<li>Number (bzw. Integer / Float)</li>
+								<li>Boolean</li>
+								<li>String</li>
+								<li>Array</li>
+								<li>Object</li>
+							</ul>
+						</p>
+					</section>
+					<section>
+						<p>Der äußere Container kann ein Array oder ein Object sein</p>
+						<pre>
+							<code class="js" data-trim data-line-numbers>
+								{
+									"key": "value",
+								}
+							</code>
+						</pre>
+						<pre>
+							<code class="js" data-trim data-line-numbers>
+								[
+									"foo",
+									"bar"
+								]
+							</code>
+						</pre>
 					</section>
 				</section>
 			</div>

--
Gitblit v1.9.3