Skip to content

Commit 1a38312

Browse files
committed
allow base url
1 parent 78cb784 commit 1a38312

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Illuminate/Http/Client/PendingRequest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ class PendingRequest
1515
*/
1616
protected $factory;
1717

18+
/**
19+
* The base URL for the request.
20+
*
21+
* @var string
22+
*/
23+
protected $baseUrl = '';
24+
1825
/**
1926
* The request body format.
2027
*
@@ -99,6 +106,19 @@ public function __construct(Factory $factory = null)
99106
}]);
100107
}
101108

109+
/**
110+
* Set the base URL for the pending request.
111+
*
112+
* @param string $url
113+
* @return $this
114+
*/
115+
public function baseUrl(string $url)
116+
{
117+
$this->baseUrl = $url;
118+
119+
return $this;
120+
}
121+
102122
/**
103123
* Indicate the request contains JSON.
104124
*
@@ -435,6 +455,8 @@ public function delete($url, $data = [])
435455
*/
436456
public function send(string $method, string $url, array $options = [])
437457
{
458+
$url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
459+
438460
if (isset($options[$this->bodyFormat])) {
439461
$options[$this->bodyFormat] = array_merge(
440462
$options[$this->bodyFormat], $this->pendingFiles

0 commit comments

Comments
 (0)