Skip to content

Commit 20298b3

Browse files
author
Edison Calle
committed
Addressing PR feedback
1 parent bf2bb1a commit 20298b3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/org/apache/hadoop/tools/Curl.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,17 @@ private function _exec($options, $returnInfo = false)
213213
}
214214
}
215215
if (!$has_content_length_header && !isset($options[CURLOPT_INFILE]) && !isset($options[CURLOPT_INFILESIZE])) {
216-
$length = 0;
217216
if (isset($options[CURLOPT_POSTFIELDS])) {
218-
$length = strlen($options[CURLOPT_POSTFIELDS]);
217+
// only for string content
218+
if (is_string($options[CURLOPT_POSTFIELDS]) && strpos($options[CURLOPT_POSTFIELDS], '@') !== 0) {
219+
$options[CURLOPT_HTTPHEADER] = array_merge(
220+
$options[CURLOPT_HTTPHEADER],
221+
['Content-Length: '.strlen($options[CURLOPT_POSTFIELDS])]
222+
);
223+
}
224+
} else {
225+
$options[CURLOPT_HTTPHEADER] = array_merge($options[CURLOPT_HTTPHEADER], ['Content-Length: 0']);
219226
}
220-
$options[CURLOPT_HTTPHEADER] = array_merge($options[CURLOPT_HTTPHEADER], ['Content-Length: ' . $length]);
221227
}
222228

223229
curl_setopt_array($ch, $options);

0 commit comments

Comments
 (0)