feat(json_client): headers param on JsonClient.get — If-None-Match → 304 conditional reads

Open
#165 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start by reading campus_python/json_client/interface.py and trace JsonClient.get through its concrete implementations and test doubles named in the issue, including CampusRequest. The proposal also mentions Files.get_content, BySlugCollection.get_content, and Files.File.get_content; check their tests before deciding the scope. Done means conditional requests can send If-None-Match and handle 304 as described, with the affected implementations and tests updated.

Written by the indexing model from the issue text.

Description

Deferred from #125 / PR #164: campus.api /files content responses (by-slug and by-id) emit an ETag ({size}-{updated_at}) and honor If-None-Match with 304 Not Modified, but the SDK cannot send conditional requests — JsonClient.get(path, query=None) has no headers parameter.

Proposal

  • Add headers: Mapping[str, str] | None = None to JsonClient.get (and, if wanted, the other verbs) in campus_python/json_client/interface.py.
  • Files.get_content / BySlugCollection.get_content / Files.File.get_content could then accept an etag param: send If-None-Match, and on 304 return None (caller keeps its cached copy) instead of raising.

Why not now

A signature change on the client ABC ripples into every concrete implementation and test double fleet-wide (CampusRequest, the campus-suite TestCampusRequest, nyxchange/classroom/admin doubles). Content responses already carry max-age=60, so plain HTTP-layer caching works today; conditional revalidation is a nice-to-have that deserves its own coordinated change.

Refs: #125, #164, campus#1007 (server ETag semantics).

Dominant language
Python
Stars
0
Forks
0
Avg merge
50m
Merged PRs (30d)
48

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nyjc-computing/campus-api-python

All issues in nyjc-computing/campus-api-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.