Skip to content

Commit 7fd5153

Browse files
committed
ext/curl: add tests for CURLOPT_INFILESIZE(_LARGE)
1 parent 195467f commit 7fd5153

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

ext/curl/tests/Caddyfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ respond /serverpush "main response"
1212
respond /serverpush/pushed "pushed response"
1313
push /serverpush /serverpush/pushed
1414

15+
route /show_upload_size {
16+
templates
17+
respond `Content-length: ={{.Req.Header.Get "Content-length"}}=`
18+
}
19+
1520
basic_auth /http-basic-auth {
1621
# bcrypt password hash for "password", calculated with 'caddy hash-password'
1722
user $2a$14$yUKl9SGqVTAAqPTzLup.DefsbXXx3kfreNnzpJOUHcIrKnr5lgef2
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
Curl option CURLOPT_INFILESIZE_LARGE
3+
--EXTENSIONS--
4+
curl
5+
--SKIPIF--
6+
<?php
7+
include 'skipif-nocaddy.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
$ch = curl_init("https://localhost/show_upload_size");
12+
$f = fopen(__FILE__,"r");
13+
var_dump(curl_setopt_array($ch, [
14+
CURLOPT_RETURNTRANSFER => true,
15+
CURLOPT_UPLOAD => true,
16+
CURLOPT_INFILE => $f,
17+
CURLOPT_INFILESIZE => filesize(__FILE__),
18+
CURLOPT_CONNECTTIMEOUT => 3,
19+
CURLOPT_TIMEOUT => 3,
20+
CURLOPT_SSL_VERIFYHOST => 0,
21+
CURLOPT_SSL_VERIFYPEER => 0,
22+
]));
23+
24+
var_dump(curl_exec($ch));
25+
26+
var_dump(curl_setopt($ch, CURLOPT_INFILESIZE, -1));
27+
var_dump(curl_exec($ch));
28+
29+
var_dump(curl_setopt($ch, CURLOPT_INFILESIZE_LARGE, -1));
30+
var_dump(curl_exec($ch));
31+
32+
rewind($f);
33+
var_dump(curl_setopt($ch, CURLOPT_INFILESIZE, filesize(__FILE__)));
34+
var_dump(curl_exec($ch));
35+
var_dump(curl_setopt($ch, CURLOPT_INFILESIZE_LARGE, -1));
36+
var_dump(curl_exec($ch));
37+
38+
rewind($f);
39+
var_dump(curl_setopt($ch, CURLOPT_INFILESIZE_LARGE, filesize(__FILE__)));
40+
var_dump(curl_exec($ch));
41+
42+
var_dump(curl_error($ch));
43+
44+
?>
45+
--EXPECTF--
46+
bool(true)
47+
string(21) "Content-length: =%d="
48+
bool(true)
49+
string(18) "Content-length: =="
50+
bool(true)
51+
string(18) "Content-length: =="
52+
bool(true)
53+
string(21) "Content-length: =%d="
54+
bool(true)
55+
string(18) "Content-length: =="
56+
bool(true)
57+
string(21) "Content-length: =%d="
58+
string(0) ""

0 commit comments

Comments
 (0)