Skip to content
Ameen Abozaid
Planned lessonJNR-017-L06

Demo: conditional GET with ETags and curl

  • Lesson 6 of 6
  • Junior
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

  1. Run the Shop API and call curl -i localhost:8080/products/1. Note the status and any ETag.
  2. Add an ETag to the response with ResponseEntity.ok().eTag("\"v" + version + "\"").
  3. Call again and copy the ETag value.
  4. Send curl -i -H 'If-None-Match: "v1"' localhost:8080/products/1 and show 304 with no body.
  5. 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.
  6. Update the product, repeat step 4, and show 200 with a new ETag.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.