Skip to content

Updated HTTP headers when a resource is created using URL - #62

Merged
tg666 merged 3 commits into
masterfrom
fix/http-headers
Mar 4, 2026
Merged

Updated HTTP headers when a resource is created using URL#62
tg666 merged 3 commits into
masterfrom
fix/http-headers

Conversation

@tg666

@tg666 tg666 commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes
    • Improved HTTP header handling when loading resources from remote URLs, now properly including language preferences and referrer information for better compatibility and reliability.

@coderabbitai

coderabbitai Bot commented Mar 4, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@tg666 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: adaf9325-037d-4f83-ac12-ec86cd8cf5c9

📥 Commits

Reviewing files that changed from the base of the PR and between 6ba0b33 and 74152da.

📒 Files selected for processing (2)
  • src/Resource/ResourceFactory.php
  • tests/Modifier/Codec/CodecTest.phpt
📝 Walkthrough

Walkthrough

The ResourceFactory.php file is updated to dynamically construct HTTP request headers when loading resources from URLs. Instead of using a hardcoded header string, the code now builds an array with Accept-language, User-Agent, and optionally Referer headers based on parsed URL information, then implodes them for the stream context.

Changes

Cohort / File(s) Summary
HTTP Header Construction
src/Resource/ResourceFactory.php
Added dynamic header construction logic in createResourceFromFile() method with Accept-language, User-Agent, and conditional Referer headers; replaced hardcoded header string with computed imploded header array; introduced implode and parse_url use statements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Headers now dance with a hop and a bound,
Accept-language and User-Agent sound,
Referer parsed with logic so keen,
Dynamic construction, a cleaner scene!
The stream context flows, efficient and free,
URLified headers, as Headers should be! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating HTTP headers when a resource is created using a URL, which aligns with the primary modification in ResourceFactory::createResourceFromFile.
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
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/http-headers

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Resource/ResourceFactory.php`:
- Around line 107-112: The Referer header built in ResourceFactory.php currently
uses sprintf with parsed URL scheme and host only, omitting non-default ports
and risking an incorrect origin; update the sprintf construction that sets
$headers[] (the Referer line using $parsedUrl['scheme'] and $parsedUrl['host'])
to append the port when isset($parsedUrl['port']) (e.g., add ':' .
$parsedUrl['port'] when present) without re-bracketing IPv6 hosts so you don't
produce double brackets, and preserve the existing line ending format.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 018c94b8-3c6b-46fc-ac30-d111f2efd887

📥 Commits

Reviewing files that changed from the base of the PR and between 6207d52 and 6ba0b33.

📒 Files selected for processing (1)
  • src/Resource/ResourceFactory.php

Comment thread src/Resource/ResourceFactory.php
@tg666
tg666 merged commit 44ecc1c into master Mar 4, 2026
8 checks passed
@tg666
tg666 deleted the fix/http-headers branch March 4, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant