Skip to content

Commit

Permalink
Deploying to gh-pages from @ 3529d17 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
damoasda committed Sep 29, 2023
1 parent b909af3 commit 8e29f69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 11 additions & 7 deletions ch20-01-single-threaded.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,10 @@ <h3 id="lesen-der-anfrage"><a class="header" href="#lesen-der-anfrage">Lesen der
wir sehen können, welche Daten vom Browser gesendet werden. Ändere den Code so,
dass er wie Codeblock 20-2 aussieht.</p>
<p><span class="filename">Dateiname: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust no_run">use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
<pre><pre class="playground"><code class="language-rust no_run">use std::{
io::{prelude::*, BufReader},
net::{TcpListener, TcpStream},
};

fn main() {
let listener = TcpListener::bind(&quot;127.0.0.1:7878&quot;).unwrap();
Expand All @@ -301,11 +302,14 @@ <h3 id="lesen-der-anfrage"><a class="header" href="#lesen-der-anfrage">Lesen der
}

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 1024];

stream.read(&amp;mut buffer).unwrap();
let buf_reader = BufReader::new(&amp;mut stream);
let http_request: Vec&lt;_&gt; = buf_reader
.lines()
.map(|result| result.unwrap())
.take_while(|line| !line.is_empty())
.collect();

println!(&quot;Request: {}&quot;, String::from_utf8_lossy(&amp;buffer[..]));
println!(&quot;Request: {:#?}&quot;, http_request);
}</code></pre></pre>
<p><span class="caption">Codeblock 20-2: Lesen aus dem <code>TcpStream</code> und Ausgeben
der Daten</span></p>
Expand Down
18 changes: 11 additions & 7 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -26712,9 +26712,10 @@ <h3 id="lesen-der-anfrage"><a class="header" href="#lesen-der-anfrage">Lesen der
wir sehen können, welche Daten vom Browser gesendet werden. Ändere den Code so,
dass er wie Codeblock 20-2 aussieht.</p>
<p><span class="filename">Dateiname: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust no_run">use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
<pre><pre class="playground"><code class="language-rust no_run">use std::{
io::{prelude::*, BufReader},
net::{TcpListener, TcpStream},
};

fn main() {
let listener = TcpListener::bind(&quot;127.0.0.1:7878&quot;).unwrap();
Expand All @@ -26727,11 +26728,14 @@ <h3 id="lesen-der-anfrage"><a class="header" href="#lesen-der-anfrage">Lesen der
}

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 1024];

stream.read(&amp;mut buffer).unwrap();
let buf_reader = BufReader::new(&amp;mut stream);
let http_request: Vec&lt;_&gt; = buf_reader
.lines()
.map(|result| result.unwrap())
.take_while(|line| !line.is_empty())
.collect();

println!(&quot;Request: {}&quot;, String::from_utf8_lossy(&amp;buffer[..]));
println!(&quot;Request: {:#?}&quot;, http_request);
}</code></pre></pre>
<p><span class="caption">Codeblock 20-2: Lesen aus dem <code>TcpStream</code> und Ausgeben
der Daten</span></p>
Expand Down

0 comments on commit 8e29f69

Please sign in to comment.