Skip to content
Snippets Groups Projects
Commit 0c114216 authored by brutzman's avatar brutzman
Browse files

https to port 443

parent b0390be4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
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