-
Notifications
You must be signed in to change notification settings - Fork 39
Added cURL formatter #50
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
Changes from 1 commit
5d03103
6056307
26687cc
105d882
ebe5202
bd069f7
24f35df
df39129
2aa729b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,13 @@ public function formatRequest(RequestInterface $request) | |
$command .= sprintf(' -H \'%s: %s\'', $name, $request->getHeaderLine($name)); | ||
} | ||
|
||
$body = $request->getBody()->__toString(); | ||
if (!empty($body)) { | ||
$command .= sprintf(' --data \'%s\'', escapeshellarg($body)); | ||
$body = $request->getBody(); | ||
if ($body->getSize() > 0) { | ||
if (!$body->isSeekable()) { | ||
throw new \RuntimeException('Cannot take data from a stream that is not seekable'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this handled outside? or should we just return something in the text that says there would be the body but we can't read it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #50 (comment) |
||
} | ||
$command .= sprintf(' --data %s', escapeshellarg($body->__toString())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i wonder if we should have some sort of sanity check to not put huge files in here? say if the body size > 5000 we truncate or just do something like [too large body] in the command? if we use this formatter eg in the symfony debug toolbar, it could break on large files |
||
$body->rewind(); | ||
} | ||
|
||
return $command; | ||
|
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.
Sending an exception here is horrible, i.e. some requests can randomly fail only on debugging (not on prod) in a symfony env with this formatter in the debug toolbar. Can we set a specific exception like : CannotFormatException (or something else) that we can catch in class using this formatter to not show something ?
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 was planning to remove this code when your request cloner is merged.