Skip to content

feature (minor): Per-parameter URL encoding opt-out (Retrofit encoded=true equivalent) #2169

Description

@glennawatson

Summary

Refit encodes URL [Query] and path segment values automatically, and the only controls are method-level ([QueryUriFormat]) or coarse (TreatAsString). There's no per-parameter way to say "this value is already encoded, pass it through verbatim." This is the feature side of bug #2002 (URL segments getting encoded with no toggle).

Prior art: Retrofit encoded

Retrofit puts an encoded flag on individual parameter annotations — @Query(value, encoded=true), @Path(value, encoded=true), @Field(..., encoded=true), @QueryMap(encoded=true). When set, Retrofit skips URL-encoding for that parameter, letting callers pass pre-encoded values.

Proposal

Add a per-parameter encoding opt-out, e.g. an Encode = false property on [Query] (and a path equivalent), so a single value can bypass automatic encoding while the rest of the request encodes normally. Resolves #2002.

Considerations

  • Interaction with UrlResolutionMode (RefitLegacy vs Rfc3986) and QueryUriFormatAttribute — define precedence (per-param should win).
  • Path-segment opt-out is the case [Bug]: URL Segments getting encoded, with seemingly no way to toggle this #2002 specifically hits; cover both query and path.
  • Reflection + source-generator paths.
  • Document the footgun: caller becomes responsible for producing valid encoded output.

Acceptance criteria

Pointers

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions