Skip to content
Snippets Groups Projects
Commit dfa3ff72 authored by bweissenbergergy's avatar bweissenbergergy
Browse files

Merge origin/master

parents 0a0553a4 394002f3
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -27,9 +27,13 @@ public class HttpWebPageSource { ...@@ -27,9 +27,13 @@ public class HttpWebPageSource {
// We request an IP to connect to a web server running on default http port 80. // We request an IP to connect to a web server running on default http port 80.
String WEB_ADDRESS = "www.nps.edu"; String WEB_SERVER_ADDRESS = "www.nps.edu";
System.out.println("New socket WEB_ADDRESS=" + WEB_ADDRESS); int WEB_SERVER_PORT_HTTP = 80;
Socket socket = new Socket(WEB_ADDRESS, 80); // compare alternative: https on port 443 int WEB_SERVER_PORT_HTTPS = 443; // does this work too?
System.out.println("New socket WEB_ADDRESS=" + WEB_SERVER_ADDRESS);
// this Java construct will work for HTTP but not HTTPS
Socket socket = new Socket(WEB_SERVER_ADDRESS, WEB_SERVER_PORT_HTTPS); // compare alternative: https on port 443
// we send a command to the web server, asking for what // we send a command to the web server, asking for what
// we want. Note that the format for the command is very // we want. Note that the format for the command is very
......
...@@ -31,3 +31,34 @@ GET /index.html HTTP/1.0 ...@@ -31,3 +31,34 @@ GET /index.html HTTP/1.0
15: </body></html> 15: </body></html>
HttpWebPageSource: response finished HttpWebPageSource: response finished
BUILD SUCCESSFUL (total time: 2 seconds) BUILD SUCCESSFUL (total time: 2 seconds)
now using https to port 443:
run-single:
HttpWebPageSource: create http connection and retrieve default page
Reference: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
Reference: https://tools.ietf.org/html/rfc7230
Reference: https://en.wikipedia.org/wiki/CURL
New socket WEB_ADDRESS=www.nps.edu
GET /index.html HTTP/1.0
1: HTTP/1.1 400 Bad Request
2: Date: Mon, 17 Aug 2020 18:25:20 GMT
3: Server: Apache
4: Content-Length: 362
5: Connection: close
6: Content-Type: text/html; charset=iso-8859-1
7:
8: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
9: <html><head>
10: <title>400 Bad Request</title>
11: </head><body>
12: <h1>Bad Request</h1>
13: <p>Your browser sent a request that this server could not understand.<br />
14: Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
15: Instead use the HTTPS scheme to access this URL, please.<br />
16: </p>
17: </body></html>
HttpWebPageSource: response finished
BUILD SUCCESSFUL (total time: 2 seconds)
examples/src/HttpServletExamples/JavaServletArchitecture.png

99.7 KiB

File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment