AAcceptMatrix
Workflows

Coding workflows · HTTP media preferences

03
Built around your work

A concrete starting point

Choose between JSON and plain text using already parsed Accept ranges. Test an exact type with quality zero beside a positive wildcard and an empty preference list, respecting specific exclusions instead of letting the wildcard override them.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

HTTP media preferences

A concrete starting point
def choose_media(ranges):
    offered = ["application/json", "text/plain"]
    if not ranges:
        return offered[0]
    choices = []
    for i, media in enumerate(offered):
        family = media.split("/")[0] + "/*"
        matches = [(2 if p == media else 1 if p == family else 0, q)
                   for p, q in ranges if p in (media, family, "*/*")]
        quality = max(matches, default=(-1, 0))[1]
        if quality > 0:
            choices.append((quality, -i, media))
    return max(choices)[2] if choices else None

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗