You are here

function soap_transport_http::decodeChunked in Salesforce Suite 5.2

Same name in this branch
  1. 5.2 includes/nusoap.php \soap_transport_http::decodeChunked()
  2. 5.2 includes/nusoap.orig.php \soap_transport_http::decodeChunked()
Same name and namespace in other branches
  1. 5 includes/nusoap.php \soap_transport_http::decodeChunked()
  2. 5 includes/nusoap.orig.php \soap_transport_http::decodeChunked()

* decode a string that is encoded w/ "chunked' transfer encoding * as defined in RFC2068 19.4.6 * *

Parameters

string $buffer: * @param string $lb * @returns string * @access public * @deprecated

File

includes/nusoap.php, line 2420

Class

soap_transport_http
transport class for sending/receiving data via HTTP and HTTPS NOTE: PHP must be compiled with the CURL extension for HTTPS support

Code

function decodeChunked($buffer, $lb) {

  // length := 0
  $length = 0;
  $new = '';

  // read chunk-size, chunk-extension (if any) and CRLF
  // get the position of the linebreak
  $chunkend = strpos($buffer, $lb);
  if ($chunkend == FALSE) {
    $this
      ->debug('no linebreak found in decodeChunked');
    return $new;
  }
  $temp = substr($buffer, 0, $chunkend);
  $chunk_size = hexdec(trim($temp));
  $chunkstart = $chunkend + strlen($lb);

  // while (chunk-size > 0) {
  while ($chunk_size > 0) {
    $this
      ->debug("chunkstart: {$chunkstart} chunk_size: {$chunk_size}");
    $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);

    // Just in case we got a broken connection
    if ($chunkend == FALSE) {
      $chunk = substr($buffer, $chunkstart);

      // append chunk-data to entity-body
      $new .= $chunk;
      $length += strlen($chunk);
      break;
    }

    // read chunk-data and CRLF
    $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);

    // append chunk-data to entity-body
    $new .= $chunk;

    // length := length + chunk-size
    $length += strlen($chunk);

    // read chunk-size and CRLF
    $chunkstart = $chunkend + strlen($lb);
    $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
    if ($chunkend == FALSE) {
      break;

      //Just in case we got a broken connection
    }
    $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
    $chunk_size = hexdec(trim($temp));
    $chunkstart = $chunkend;
  }
  return $new;
}