generated from mwc/lab_riddles
completed riddles checkpoint 2
1. The "shopping cart" interface on an online store might be a series of requests from the user to go to product pages and add items to cart. Part of the response would be an update to the shopping cart and on something like Amazon, the indicator in the corner telling you how many items are currently in your cart. I feel like the product page would bet a GET and adding an item to cart would be a POST? I'm not sure how the readout on the site itself would be handled, whether by GET or a different method entirely. 2. So the specifics of what things like "X-Content-Type-Options" and "X-Frame-Options" actually mean are still foreign to me, but it makes sense that navigating a page, interacting with elements on a page, and anything else in that vein would involve some method of communicating between the client and the server. Looking at this now, I can see why GET and POST are the most common methods used in HTTP requests.
This commit is contained in:
parent
8206910718
commit
1c2ee8c4a0
100
notes.md
100
notes.md
|
@ -33,3 +33,103 @@ receiving, I can have it automatically parsed and formatted.
|
|||
The goal of this checkpoint is to see what status codes you can get back from
|
||||
the riddle server. Paste below several `http` requests and the status codes
|
||||
they return.
|
||||
|
||||
Using an ID number that does not exist:
|
||||
$ http -v post https://riddles.makingwithcode.org/guess id=15 answer="a short-legged cow"
|
||||
POST /guess HTTP/1.1
|
||||
Accept: application/json, */*;q=0.5
|
||||
Accept-Encoding: gzip, deflate
|
||||
Connection: keep-alive
|
||||
Content-Length: 44
|
||||
Content-Type: application/json
|
||||
Host: riddles.makingwithcode.org
|
||||
User-Agent: HTTPie/3.2.2
|
||||
|
||||
{
|
||||
"answer": "a short-legged cow",
|
||||
"id": "15"
|
||||
}
|
||||
|
||||
|
||||
HTTP/1.1 400 Bad Request
|
||||
Connection: keep-alive
|
||||
Content-Length: 13
|
||||
Content-Type: application/json
|
||||
Cross-Origin-Opener-Policy: same-origin
|
||||
Date: Wed, 03 Apr 2024 18:32:37 GMT
|
||||
Referrer-Policy: same-origin
|
||||
Server: nginx/1.22.0 (Ubuntu)
|
||||
X-Content-Type-Options: nosniff
|
||||
X-Frame-Options: DENY
|
||||
|
||||
{
|
||||
"error": ""
|
||||
}
|
||||
|
||||
Using a web address with a typo in it:
|
||||
$ http -v post https://riddles.makingwithcode.org/gues id=1 answer="a short-legged cow"
|
||||
POST /gues HTTP/1.1
|
||||
Accept: application/json, */*;q=0.5
|
||||
Accept-Encoding: gzip, deflate
|
||||
Connection: keep-alive
|
||||
Content-Length: 43
|
||||
Content-Type: application/json
|
||||
Host: riddles.makingwithcode.org
|
||||
User-Agent: HTTPie/3.2.2
|
||||
|
||||
{
|
||||
"answer": "a short-legged cow",
|
||||
"id": "1"
|
||||
}
|
||||
|
||||
|
||||
HTTP/1.1 404 Not Found
|
||||
Connection: keep-alive
|
||||
Content-Encoding: gzip
|
||||
Content-Type: text/html; charset=utf-8
|
||||
Cross-Origin-Opener-Policy: same-origin
|
||||
Date: Wed, 03 Apr 2024 18:34:02 GMT
|
||||
Referrer-Policy: same-origin
|
||||
Server: nginx/1.22.0 (Ubuntu)
|
||||
Transfer-Encoding: chunked
|
||||
X-Content-Type-Options: nosniff
|
||||
X-Frame-Options: DENY
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Not Found</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Not Found</h1><p>The requested resource was not found on this server.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Using a method that doesn't exist:
|
||||
$ http -v past https://riddles.makingwithcode.org/guess id=1 answer="a short-legged cow"
|
||||
PAST /guess HTTP/1.1
|
||||
Accept: application/json, */*;q=0.5
|
||||
Accept-Encoding: gzip, deflate
|
||||
Connection: keep-alive
|
||||
Content-Length: 43
|
||||
Content-Type: application/json
|
||||
Host: riddles.makingwithcode.org
|
||||
User-Agent: HTTPie/3.2.2
|
||||
|
||||
{
|
||||
"answer": "a short-legged cow",
|
||||
"id": "1"
|
||||
}
|
||||
|
||||
|
||||
HTTP/1.1 405 Method Not Allowed
|
||||
Allow: POST
|
||||
Connection: keep-alive
|
||||
Content-Length: 0
|
||||
Content-Type: text/html; charset=utf-8
|
||||
Cross-Origin-Opener-Policy: same-origin
|
||||
Date: Wed, 03 Apr 2024 18:36:06 GMT
|
||||
Referrer-Policy: same-origin
|
||||
Server: nginx/1.22.0 (Ubuntu)
|
||||
X-Content-Type-Options: nosniff
|
||||
X-Frame-Options: DENY
|
Loading…
Reference in New Issue