-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Profiler] Add HttpClient copy as curl feature #37691
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
[Profiler] Add HttpClient copy as curl feature #37691
Conversation
e987f84
to
a00ba1b
Compare
{% endblock %} | ||
|
||
{% macro render_curl(trace) %} | ||
curl "{{ trace.url }}" --compressed -H "Connection: keep-alive" -v |
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.
if we can provide a reusable service (request to curl) that be neat :) i believe there are some CurlBuilders in the wild to take inspiration from.
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.
well, I would say that it must at least include the method and the headers. For the body, that's harder.
Also, be careful about the fact that you need to escape "
in the command arguments (or even better apply proper shell escaping, which might imply moving this logic to a helper method in the collector class rather than doing it in a twig macro)
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.
moving this logic to a helper method in the collector class
would there be any reason to not make it a first class feature, if we want this feature for the profiler?
a usecase i have in mind is adding the curl command in some log entries its context. Or perhaps display in CLI verbose mode.
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.
well, if you want to make it a first-class feature, the argument of this API cannot be the internal data structure of this collector
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.
Maybe it will be easier in the datacollector, agreed i'll move this
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.
For a ref, the curl formatter used by httplug: https://github.com/php-http/message/blob/master/src/Formatter/CurlCommandFormatter.php
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.
i'll check this thx
|
||
document.querySelectorAll('[data-clipboard-text]').forEach(function(button) { | ||
button.addEventListener('click', function() { | ||
navigator.clipboard.writeText(button.getAttribute('data-clipboard-text')); |
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.
instead of writing support for Copy to clipboard
as an inline script in this panel, I suggest adding such a feature in the shared JS of the profiler pages, so that it can be reused by any other panel too (as we do for tabs and toggles).
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.
I'll refactor indeed
Closing because this staled and there is a lot of work remaining. Please resubmit when you think this is ready for review (not as a draft then :) ) |
Agreed, will try to find time to continue this if i can |
@noniagriconomie How far is your progress? I need this feature for my current project and was thinking about building it for myself. In case you're not actively working on the feature: Any objects if I take over? I don't want to steal your contribution. |
Will do, thanks! |
I want to continue this PR; however, there is not all data in trace to generate correct CURL command. Trace contains only method, url and raw options without preparing such as json. I think |
Maybe open a new issue linking this one as reference to discuss the continuity/specifications @maranqz |
@maranqz No, you need to save more information in the trace than we currently do. That's more or less why I haven't made much progress on the PR either. |
PR draft
Folowing #37690
i wanted to see some issues on the httpclient and found this one #33311
i can work on both ping @nicolas-grekas
what do you have in mind for
we should maybe have a better display too
?curl
request can be complex, what is the MVP wanted here?Thanks :)