public function getLength()
{
if (isset($this->cachedLength)) {
return new Success($this->cachedLength);
} elseif ($this->isMultipart) {
$fields = $this->getMultipartFieldArray();
$length = $this->sumMultipartFieldLengths($fields);
$length->when(function ($error, $result) {
if (empty($error)) {
$this->cachedLength = $result;
}
});
return $length;
} else {
$length = strlen($this->getFormEncodedBodyString());
return new Success($length);
}
}