Skip to content

feat: support Request method strings and priority hints#48

Merged
medz merged 2 commits into
mainfrom
fix/request-method-priority
Jun 22, 2026
Merged

feat: support Request method strings and priority hints#48
medz merged 2 commits into
mainfrom
fix/request-method-priority

Conversation

@medz

@medz medz commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Change RequestInit.method and Request.method to string semantics so custom methods such as PROPFIND are representable.
  • Add RequestPriority and RequestInit.priority as a lightweight Fetch priority hint model.
  • Keep signal and targetAddressSpace out of scope: signal is request runtime cancellation, and targetAddressSpace is browser-only security metadata.
  • Update README/example usage and request tests for native, IO, and JS wrappers.

Runtime behavior checked

  • Node v26 and Chrome normalize get/post to GET/POST, preserve custom/lower non-normalized methods such as propfind and patch, reject invalid method tokens and forbidden methods, and reject GET/HEAD bodies.
  • Chrome and Node validate priority init values as high/low/auto, while the constructed Request object does not expose a readable priority property.
  • Bun 1.3.14 is looser around invalid/forbidden methods and GET/HEAD bodies, so this change follows Chrome/Node Fetch semantics instead of Bun fallback behavior.

Validation

  • dart analyze
  • dart test
  • dart test -p chrome

Closes #42
Closes #36

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced RequestPriority enum with values auto, high, and low.
    • Added priority parameter to RequestInit and corresponding field on Request.
  • Breaking Changes

    • Request.method now returns a String instead of an HttpMethod enum value.
  • Documentation

    • Updated code examples to use HTTP method string literals.

@medz medz added bug Something isn't working enhancement New feature or request labels Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@medz, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 51 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a33b974d-0565-4d87-965d-cd4b28d0f1a5

📥 Commits

Reviewing files that changed from the base of the PR and between a014433 and 919a180.

📒 Files selected for processing (2)
  • lib/src/fetch/request.io.dart
  • test/request_io_test.dart
📝 Walkthrough

Walkthrough

Request.method and RequestInit.method are changed from HttpMethod enum to a normalized String. A new RequestPriority enum (auto, high, low) is introduced and wired through RequestInit, Request, and both IO and JS platform implementations. Method validation/normalization is reimplemented as regex-based string logic. All tests, examples, and docs are updated accordingly.

Changes

Request method→String and RequestPriority

Layer / File(s) Summary
Native contracts: method→String, RequestPriority, normalization
lib/src/fetch/request.native.dart
Removes HttpMethod import; adds RequestPriority enum; changes RequestInit.method/Request.method to String; adds priority field to both; replaces enum-based _methodFromInput with regex validation, forbidden-method rejection, and string normalization; updates _bodyFromInput and clone() to carry priority.
IO and JS platform implementations + re-export wiring
lib/src/fetch/request.io.dart, lib/src/fetch/request.js.dart, lib/src/fetch/request.dart
Removes HttpMethod imports; changes Request.method getter to return raw String from host; adds priority getter (defaulting to auto for web/HTTP hosts, forwarding for native hosts); propagates priority into clone(), _nativeRequestFromWrappedRequest, and _nativeRequestFromWebRequest; replaces _allowsRequestBody(HttpMethod) with _allowsRequestBody(String); re-exports RequestPriority.
Tests, public API surface, docs, and examples
test/request_native_test.dart, test/request_io_test.dart, test/request_js_test.dart, test/public_api_surface_test.dart, README.md, example/main.dart
Removes HttpMethod imports across all test files; replaces all HttpMethod.* constants with string literals in RequestInit constructions and Request.method assertions; adds priority assertions; adds JS test for custom-method preservation and priority through clone(); updates public API surface test to assert requestInit.method and requestInit.priority; updates README and example to use 'POST' string literals.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • medz/ht#11: Introduces the RequestInit init container and wires request construction around it — the same RequestInit struct whose method type and priority field are changed in this PR.
  • medz/ht#12: Adds the cross-runtime Request primitives with HttpMethod-based method handling in the native/IO/JS layers that this PR replaces with normalized String methods.

Poem

🐇 No more enum for the method I send,
A 'POST' string literal is now the trend!
With RequestPriorityauto, high, low
My fetch hops faster wherever I go.
The rabbit refactored, the tests all agree:
String methods and priority, living in harmony! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly summarizes the main changes: converting Request.method from HttpMethod enum to string semantics and adding RequestPriority support.
Linked Issues check ✅ Passed PR successfully implements custom HTTP method support via strings and adds RequestPriority, directly addressing #42's investigation scope and meeting the requirements from both linked issues.
Out of Scope Changes check ✅ Passed All changes are directly related to supporting string-based HTTP methods and RequestPriority. Signal and targetAddressSpace are explicitly excluded as documented in PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/request-method-priority

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@medz medz removed the bug Something isn't working label Jun 22, 2026
@medz medz changed the title fix: align RequestInit method and priority semantics feat: support Request method strings and priority hints Jun 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0144337ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/src/fetch/request.io.dart
@medz medz merged commit f8153b5 into main Jun 22, 2026
2 checks passed
@medz medz deleted the fix/request-method-priority branch June 22, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decide RequestInit method and modern Fetch surface parity Align Fetch-like APIs with MDN semantics

1 participant