Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change HTTP client in symfony/cache to Curl #296

Merged
merged 19 commits into from
May 23, 2024
Merged

Conversation

koriym
Copy link
Member

@koriym koriym commented Apr 29, 2024

Summary by CodeRabbit

  • 新機能

    • cURLを使用してHTTPリクエストを送信するための新しいクラスとインターフェースが導入されました。
    • 特定のHTTPヘッダーでHTML応答をテストする新しいテストメソッドが追加されました。
  • バグ修正

    • HTTPリクエストヘッダーのチェックを追加し、'text/html'の場合はHTML内容で応答するように変更しました。
  • リファクタリング

    • HTTPリクエストの処理をHttpRequestInterfaceに委任するようにHttpResourceObjectクラスが大幅にリファクタリングされました。
  • その他の変更

    • 不要な依存関係を削除し、必要な拡張機能を追加しました。

koriym added 5 commits April 27, 2024 16:26
The HTTP client used in 'HttpResourceObject' has been switched from Symfony's HttpClient to cURL for better functionality and flexibility. This includes separate handling for response headers and body, support for various content types and improved error handling. Necessary constants and functions have been added and relevant tests have been updated accordingly.
Refactor HTTP Request processing in HttpResourceObject

The HTTP request processing method in HttpResourceObject has been significantly refactored for clarity and efficiency. The adjustments include the reconsideration of how the request body is encoded, the simplification of handling different content types, and the elimination of unnecessary methods in the HttpResourceObjectTest. Also, better type safety has been added with more type hinting and assertions.
The function `setProps` in `HttpResourceObject` has been renamed to `httpRequest` to better reflect its purpose. The change is applied in both the method definition and its usage site, with no change in the parameters or the method body.
"ext-curl" was added to the list of requirements in composer.json. This ensures necessary curl extension for handling HTTP requests is available for the application, improving the project's code organization and maintainability.
…stCurl

The HttpAccessCurl class has been extensively refactored which involved renaming it to HttpRequestCurl. HTTP request functions and methods have been removed from HttpResourceObject and added to HttpRequestCurl instead. This includes changing the httpRequest method to return an array instead of modifying a ResourceObject in-place. Also, methods were updated to improve error checking and clarity.
Copy link

coderabbitai bot commented Apr 29, 2024

Important

Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

概要

この変更では、HTTPリクエストの処理方法がcURLを使用する方式に変更されました。composer.jsonでは依存関係が更新され、新しいHttpRequestCurlクラスが導入されています。また、HttpResourceObjectクラスがリファクタリングされ、HTTPリクエストのインタフェースが簡素化されています。テストも更新され、新しいHTTPレスポンスの処理が追加されています。

変更

ファイル 変更概要
composer.json "ext-curl": "*" を追加し、いくつかの依存関係を削除
src/HttpRequestCurl.php cURLを使用してHTTPリクエストを送信するための新クラスを導入
src/HttpRequestInterface.php HTTPリクエストを送信するためのインタフェースを導入
src/HttpRequestHeaders.php HTTPリクエストヘッダを表すクラスを導入
src/HttpResourceObject.php クラス構造を大幅にリファクタリングし、HttpRequestInterfaceに依存するように変更
src/Module/HttpClientModule.php HttpClientInterfaceのバインディングをHttpRequestInterfaceに置き換え、HttpRequestHeadersを追加
tests/... テストを更新し、新しいHTTPリクエストヘッダのセットアップとHTMLレスポンスのテストを追加
tests/Server/index.php 'Content-Type' ヘッダに基づいてHTMLまたはJSONレスポンスを返すように変更

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@koriym
Copy link
Member Author

koriym commented Apr 29, 2024

@coderabbitai review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

src/HttpRequestInterface.php Outdated Show resolved Hide resolved
src/HttpRequestInterface.php Show resolved Hide resolved
@koriym koriym marked this pull request as ready for review April 29, 2024 12:01
@koriym koriym requested a review from NaokiTsuchiya April 29, 2024 12:13
koriym added 10 commits April 29, 2024 21:22
HttpClientProvider class and several dependencies related to it have been removed from the project. The HttpClientModule has been refactored to bring about better efficiency in handling HTTP requests and improve overall code clarity. It now makes use of HttpRequestCurl instead of HttpClientInterface.
Symphony's HttpClientInterface was replaced with BEAR's HttpRequestCurl in the HttpClientModule. This change aims to streamline the handling of HTTP requests, improve code clarity, and offload dependencies tied
The HttpRequestCurl class was refactored to improve code readability and simplicity. The unnecessary CURLFile import was removed, the PHPStan ignore line was cleaned up, and multipart form-data handling was stripped due to its redundancy. This results in a leaner, more focused HTTP request implementation.
The HttpRequestCurl class was refactored, improving readability and reducing complexity. The conditionally setting of Curl options has been extracted into a new method, setCurlRequestPayload. This change makes the code cleaner and easier to understand. Furthermore, the CURLFile import has been removed as it was not needed.
This commit focuses on refactoring the HttpRequestCurl class to enhance its type safety. Various changes have been made including removing unnecessary functions, adding type annotations, splitting a complex function into smaller, more manageable ones, and changing the way headers are processed. This will help improve code readability, maintenance and reduce potential typing errors.
This commit refactors the HttpRequestCurl class to increase type safety. Removed redundant assertions, added type assertions for method parameters, and streamlined header processing. These
This commit refines the HttpRequestCurl class to improve type safety and code clarity. By introducing explicit type checks for method parameters and simplifying header handling, not only is the code readability improved but also potential typing errors are minimized.
The HttpRequestCurl class has been updated to improve type safety and readability of the code. The changes include refining method parameters to use explicit types, simplifying the handling of content types in headers, and eliminating the unnecessary encoding section. This aims to minimize the potential for typing errors and boost the efficiency of requests made by the HTTP client.
The HttpRequestCurl now implements a new HttpRequestInterface, resulting in a more robust and flexible design. The switch over from HttpRequestCurl to HttpRequestInterface in HttpResourceObject and HttpClientModule is reflected aswell.  Additionlly, tests and server-side scripts have been updated to handle HTML responses and accompanying headers properly. This enhances the system's capability to handle different types of requests and makes the test suite more comprehensive.
The 'nikic/php-parser' dependency has been removed from the project files. This change is reflected in the composer.json file where the associated line has been deleted. Now the project relies on fewer third-party packages, thereby reducing potential security risks and improving overall application performance.
src/HttpRequestCurl.php Outdated Show resolved Hide resolved
src/HttpRequestInterface.php Outdated Show resolved Hide resolved
src/HttpRequestInterface.php Outdated Show resolved Hide resolved
src/HttpRequestCurl.php Show resolved Hide resolved
koriym and others added 4 commits May 23, 2024 18:15
Co-authored-by: Naoki Tsuchiya <ntsuchiya1105@gmail.com>
Co-authored-by: Naoki Tsuchiya <ntsuchiya1105@gmail.com>
Co-authored-by: Naoki Tsuchiya <ntsuchiya1105@gmail.com>
This commit removes an extraneous line of whitespace from the HttpRequestCurl
@koriym koriym merged commit 35ac6ef into bearsunday:1.x May 23, 2024
13 checks passed
@koriym koriym deleted the curl branch May 23, 2024 11:50
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.

2 participants