Demo: conditional GET with ETags and curl
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
watch a 304 happen. Prepares JNR-017-LAB1.
Draft outline details
Step by step
- Run the Shop API and call
curl -i localhost:8080/products/1. Note the status and anyETag. - Add an ETag to the response with
ResponseEntity.ok().eTag("\"v" + version + "\""). - Call again and copy the
ETagvalue. - Send
curl -i -H 'If-None-Match: "v1"' localhost:8080/products/1and show304with no body. - Planned mistake: send the ETag without the quotes. The server treats it as a different value and returns
200. Fix: ETags are quoted strings; copy them exactly. - Update the product, repeat step 4, and show
200with a new ETag.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.