Skip to content

Commit

Permalink
updated web page
Browse files Browse the repository at this point in the history
  • Loading branch information
s-archer committed Sep 10, 2024
1 parent 79cee12 commit ae12721
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
22 changes: 21 additions & 1 deletion http.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,34 @@ function path_rule(r) {
} else if (r.uri === "/summary") {
title = "Summary of Headers Received";
bodyText = summary(r);
} else {
} else {
title = "Unknown Page";
bodyText = "This page is not recognized.";
}

// Set the correct Content-Type header
r.headersOut['Content-Type'] = 'text/html';

if (r.uri === "/response-headers") {
r.headersOut['Content-Type'] = 'text/html';
r.headersOut['Strict-Transport-Security'] = 'max-age=20000000';
title = "Hello Page";
bodyText = "Welcome to the Reponse Headers Page! Look at develor tools to see the headers</p>";
}

if (r.uri === "/response-headers") {
r.headersOut['Content-Type'] = 'text/html';
r.headersOut['Strict-Transport-Security'] = 'max-age=20000000';
title = "Hello Page";
bodyText = "Welcome to the Response Headers Page! Look at developer tools to see the following headers:</p>";

// Iterate over r.headersOut and append them to the bodyText
bodyText += "<h2>Response Headers:</h2>";
for (const header in r.headersOut) {
bodyText += `<p>${header}: ${r.headersOut[header]}</p>`;
}
}

// Return the dynamically generated HTML
r.return(200, generateHtml(title, bodyText));
}
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ <h1>Welcome to My Website</h1>
<a href="/hello">Go to Hello</a>
<a href="/summary">Go to Summary</a>
<a href="/redirect">Go to Get Redirected</a>
<a href="/response-headers">Go to Get Response Headers</a>
</body>
</html>
4 changes: 4 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ http {
location = /redirected {
return 200 $path_rule;
}

location = /response-headers {
return 200 $path_rule;
}
}
}

0 comments on commit ae12721

Please sign in to comment.