Skip to content

Commit 0fa021a

Browse files
committed
:octocat: allow http & add URL to HTTPResponse
1 parent 3f2726a commit 0fa021a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/TinyCurlClient.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,22 @@ public function request(string $url, array $params = null, string $method = null
4848

4949
$parsedURL = parse_url($url);
5050

51-
if(!isset($parsedURL['host']) || $parsedURL['scheme'] !== 'https'){
51+
if(!isset($parsedURL['host']) || !in_array($parsedURL['scheme'], ['http', 'https'], true)){
5252
trigger_error('invalid URL');
5353
}
5454

55-
$response = $this->http->fetch(new URL(
55+
$url = new URL(
5656
explode('?', $url)[0],
5757
$params ?? [],
5858
$method ?? 'POST',
5959
$body,
6060
$headers ?? []
61-
));
61+
);
62+
63+
$response = $this->http->fetch($url);
6264

6365
return new HTTPResponse([
66+
'url' => $url->__toString(),
6467
'headers' => $response->headers,
6568
'body' => $response->body->content,
6669
]);

0 commit comments

Comments
 (0)