cmda-bt / be-course-17-18

🎓 Backend · 2017-2018 · Curriculum and Syllabus 💾
Other
47 stars 19 forks source link

Transfer assignment #499

Closed DanielvandeVelde closed 6 years ago

DanielvandeVelde commented 6 years ago

My findings

  1. It's localhost, not localghost. Repeatedly trying to connect to your local ghost will not work.
  2. '*" is for packets, '>' is a request to the server, '<' is the server's response
  3. Requests are (method + path + protocol + version ) e.g. (GET / HTTP / 1.1 )
  4. Status 4xx is a client error, 2xx is succes(?)
  5. HEAD can be used to check if things exist
  6. PUT is for a whole resource, but you do need to send other properties even if you're not changing those.
  7. To change a few things we can use PATCH
  8. If we want to receive other types of information we can use '--header' after our GET request and the specifics 'application/xml' to receive XML.
  9. We can also use Accept-Encoding to get the information encrypted.

I love how the ending of the last step is 'other than that, you've done very well'. So if I understand it correctly, in "real-life" you would not really use OPTIONS and PATCH. Is there a specific reason for that? Is there a better way or is it just something that you don't really use?

rijkvanzanten commented 6 years ago

Repeatedly trying to connect to your local ghost will not work

😂

So if I understand it correctly, in "real-life" you would not really use OPTIONS and PATCH. Is there a specific reason for that?

That's not entirely true! OPTIONS is often used by the browser to check if the server accepts the domain your website is using in CORS (https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) and PATCH has a slight semantic difference from PUT. PUT is updating a whole entity, where PATCH can be used to update one or more properties in a single entity. It gets very technical very quickly, but it's an interesting subject to dive into :) https://stackoverflow.com/questions/28459418/rest-api-put-vs-patch-with-real-life-examples