A kiválasztott változat és az aktuális verzió közötti különbségek a következők.
| Előző változat mindkét oldalon Előző változat Következő változat | Előző változat | ||
|
tanszek:oktatas:iss_t:http_server [2023/03/12 17:52] knehez |
tanszek:oktatas:iss_t:http_server [2024/03/04 08:09] (aktuális) knehez |
||
|---|---|---|---|
| Sor 7: | Sor 7: | ||
| Content of //404.html//: | Content of //404.html//: | ||
| - | <code html> | + | <sxh html> |
| <html> | <html> | ||
| <body> | <body> | ||
| Sor 13: | Sor 13: | ||
| </body> | </body> | ||
| </html> | </html> | ||
| - | </code> | + | </sxh> |
| Content of //index.html//: | Content of //index.html//: | ||
| - | <code html> | + | <sxh html> |
| <html> | <html> | ||
| <body> | <body> | ||
| Sor 23: | Sor 23: | ||
| </body> | </body> | ||
| </html> | </html> | ||
| - | </code> | + | </sxh> |
| Content of //JavaHTTPServer.java//: | Content of //JavaHTTPServer.java//: | ||
| - | <code java> | + | <sxh java> |
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||
| Sor 182: | Sor 182: | ||
| } | } | ||
| - | </code> | + | </sxh> |
| - | **Task**: refactor the code and eliminate duplicate parts. Let's create a separate function to return the general HTTP response:: | + | **Task**: refactor the code and eliminate duplicate parts. Let's create a separate function to return a general HTTP response:: |
| - | <code java> | + | <sxh java> |
| out.println("HTTP/1.1 200 OK"); | out.println("HTTP/1.1 200 OK"); | ||
| out.println("Server: Java HTTP Server v1.0"); | out.println("Server: Java HTTP Server v1.0"); | ||
| Sor 194: | Sor 194: | ||
| out.println(); // blank line between headers and content, very important ! | out.println(); // blank line between headers and content, very important ! | ||
| out.flush(); // flush character output stream buffer | out.flush(); // flush character output stream buffer | ||
| - | </code> | + | </sxh> |
| **Task**: modify the source code so that it can also return images. To do this, first add <img src="…> to index.html and copy an arbitrary image next to the html-s.. | **Task**: modify the source code so that it can also return images. To do this, first add <img src="…> to index.html and copy an arbitrary image next to the html-s.. | ||