-
Notifications
You must be signed in to change notification settings - Fork 27
Corrected a problem with memory #19
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
Conversation
Not replace CURLOPT_READFUNCTION. Avoid full loading large or unknown size body into memory. You can specify any method you'd like, including a custom method that might not be part of RFC 7231 (like "MOVE").
for a possibility of "extends"
…the server. fix inheritance support. fix custom reading function (CURLOPT_READFUNCTION). fix custom methods. fix PATCH with send body. fix support native PHP stream filters. fix support follow location (CURLOPT_FOLLOWLOCATION). fix compatible stream with PSR-7 specifications. fix out of memory when a large body send of response. fix "Expect" and "Accept" header. fix out of memory with sendAsyncRequest in some cases.
👍 Wow, this is super awesome, thank you. Needs a rebase though, and @mekras's review. |
@jack-theripper, can you split these changes into separate PRs? Also I have some questions and notices.
|
@mekras, how to split? This complex correction. What do you mean ?
Simple example: how to set the timeout to 1 request? $client = new Client(MessageFactory, StreamFactory, [
CURLOPT_TIMEOUT => 10
]);
// send request. timeout = 10
$client->sendRequest($request);
// send other request. timeout = 200
$client->sendRequest($request, [
CURLOPT_TIMEOUT => 200
]);
// send other request. timeout = 10
$client->sendRequest($request); 2 . The client must be flexible. Maybe, but artificial restrictions - it is bad. Should not be artificial restrictions. it's all the questions? |
At least "replace property visibility" is not necessary for other changes, so can be moved to a separate PR, to be discussed. Setting "Accept" header. May be something else. So this is the reason for splitting PR: clearly define the purpose of each code change. |
class Client implements HttpClient, HttpAsyncClient | ||
{ | ||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the extra line?
Options must be injected in the constructor.
Not quite sure what you are trying to say, but I agree with @mekras. Please don't change the visibility. And yes, it should probably be final. |
@sagikazarmark, "PSR conforming" I didn't pay attention to it, I just set in IDE code style "PSR-2" and auto code align. you use a "php-http/curl-client" in your code ? I will ask a few questions:
|
|
@sagikazarmark, There are situations when you need to get control on CreateResponse (not to spend cpu time on reading and writing streams). I work with a very very large body. I need "Except" headers and change the logic, but the client does not support. That is a quick fix, I need "extends Client", but it is forbidden to artificially. NOTE: Sorry, but it was a mistake to use this client in my project, he is such incomplete. |
@jack-theripper although I see your problem, and I think it is important to address it, I am pretty sure that it can be addressed in a proper way. The Client should be CPU and memory efficient out of the box, I don't see why you should extend it to achieve that. I saw some discussion about except headers as well. If you allow me a personal comment: crticizing others work and being rude doesn't seem to be the correct behaviour, especially if people want to help you solving your issues, even if they see the solution a bit differently. (Not to mention you are trying to enforce bad design) I think @mekras did quite a good job with this client and he keeps solving the upcoming issues efficiently. If it doesn't fit your use case, you are free to fork it and add any features you want, if you are not satisfied with our support. |
because the client out of the box works not effectively. If the client can be inherited, then it will save developers time. I didn't criticize, I just corrected a row of serious problems.
I think I should cancel pull request. I have corrected jack-theripper@abbf8fa you can use my solution. NOTE: A similar problem exists in Guzzle Client. |
@mekras can you take over this and see how we can implement it based on @jack-theripper's solution? |
@sagikazarmark, I'll check this PR any way. It would have taken less time if @jack-theripper would remove non relevant changes, such as "private → protected", "Accept" header and others. |
I have corrected some inconvenient moments and have up to the end corrected a problem with memory.
fix inheritance support.
fix custom reading function (CURLOPT_READFUNCTION).
fix custom methods.
fix "Expect" and "Accept" header.
fix PATCH with send body.
fix support native PHP stream filters.
fix support follow location (CURLOPT_FOLLOWLOCATION).
fix compatible stream with PSR-7 specifications.
fix out of memory when a large body send of response.
fix out of memory with sendAsyncRequest in some cases.