From 0c1142164c3364e92b1fb63ceae3e371e819137e Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@DESKTOP-2S09UKA>
Date: Mon, 17 Aug 2020 11:31:47 -0700
Subject: [PATCH] https to port 443

---
 .../HttpWebPageSource.java                    | 10 ++++--
 .../HttpWebPageSourceTerminalLog.txt          | 31 +++++++++++++++++++
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/examples/src/HttpServletExamples/HttpWebPageSource.java b/examples/src/HttpServletExamples/HttpWebPageSource.java
index 5996b569a4..c8777424a6 100644
--- a/examples/src/HttpServletExamples/HttpWebPageSource.java
+++ b/examples/src/HttpServletExamples/HttpWebPageSource.java
@@ -27,9 +27,13 @@ public class HttpWebPageSource {
            
            // We request an IP to connect to a web server running on default http port 80.
            
-           String WEB_ADDRESS = "www.nps.edu";
-           System.out.println("New socket WEB_ADDRESS=" + WEB_ADDRESS);
-           Socket socket = new Socket(WEB_ADDRESS, 80); // compare alternative: https on port 443
+           String WEB_SERVER_ADDRESS    = "www.nps.edu";
+           int    WEB_SERVER_PORT_HTTP  = 80;
+           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 want. Note that the format for the command is very
diff --git a/examples/src/HttpServletExamples/HttpWebPageSourceTerminalLog.txt b/examples/src/HttpServletExamples/HttpWebPageSourceTerminalLog.txt
index 896fb30c8a..9deeef11d9 100644
--- a/examples/src/HttpServletExamples/HttpWebPageSourceTerminalLog.txt
+++ b/examples/src/HttpServletExamples/HttpWebPageSourceTerminalLog.txt
@@ -31,3 +31,34 @@ GET /index.html HTTP/1.0
 15: </body></html>
 HttpWebPageSource: response finished
 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)
-- 
GitLab