Skip to content

Commit beb2cf7

Browse files
committed
setTemporary('php://temp') is no longer needed
1 parent c99d5cd commit beb2cf7

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ $proxy->setDrivers([
4242
StreamDriver::class
4343
]);
4444

45-
// Set temporary location
46-
$proxy->setTemporary('php://temp');
47-
4845
// Execute download
4946
$proxy->download($_GET['url']);
5047

@@ -204,7 +201,6 @@ $proxy->setDrivers([
204201
StreamDriver::class
205202
]);
206203

207-
$proxy->setTemporary('php://temp');
208204
$proxy->download($url);
209205

210206
$proxy->response();
@@ -228,8 +224,6 @@ $proxy->setDrivers([
228224
StreamDriver::class
229225
]);
230226

231-
$proxy->setTemporary('php://temp');
232-
233227
try {
234228
$proxy->download($url);
235229
$proxy->jsonp($_GET['callback']);
@@ -255,7 +249,6 @@ $proxy->setDrivers([
255249
StreamDriver::class
256250
]);
257251

258-
$proxy->setTemporary('php://temp');
259252
$proxy->download($url, true);
260253

261254
$errcode = $proxy->getLastErrorCode();
@@ -293,7 +286,6 @@ $proxy->urls([
293286
'*://other.io/', // Allows HTTPS and HTTP requests to other.io
294287
]);
295288

296-
$proxy->setTemporary('php://temp');
297289
$proxy->download($url);
298290
```
299291

proxy.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666
StreamDriver::class
6767
]);
6868

69-
// Set temporary location
70-
$proxy->setTemporary('php://temp');
71-
7269
// Use specific directory
7370
// $proxy->setTemporary(__DIR__ . '/cache');
7471

src/Drivers/CurlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Inphinit
3+
* Inphinit Proxy
44
*
55
* Copyright (c) 2025 Guilherme Nascimento
66
*

src/Drivers/InterfaceDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Inphinit
3+
* Inphinit Proxy
44
*
55
* Copyright (c) 2025 Guilherme Nascimento
66
*

src/Drivers/StreamDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Inphinit
3+
* Inphinit Proxy
44
*
55
* Copyright (c) 2025 Guilherme Nascimento
66
*

src/Proxy.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Inphinit
3+
* Inphinit Proxy
44
*
55
* Copyright (c) 2025 Guilherme Nascimento
66
*
@@ -181,7 +181,13 @@ public function getTemporary()
181181
public function download($url, $ignoreDownloadError = false)
182182
{
183183
if ($this->temporary === null) {
184-
$this->raise('Temporary not defined, you need set Proxy::setTemporary()');
184+
$temporary = tmpfile();
185+
186+
if ($temporary) {
187+
$this->temporary = $temporary;
188+
} else {
189+
$this->raise('Failed to open temporary file');
190+
}
185191
}
186192

187193
if ($this->validateUrl($url) === false) {

0 commit comments

Comments
 (0)