]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/package/assembler/class_PackageAssembler.php
Noisy debug line added + check if start and end markers are set.
[hub.git] / application / hub / main / package / assembler / class_PackageAssembler.php
index e737c8e42adb26bc4d0393613d69ac8fc6ae9fce..0eec7aff05545a31b66cf614aed90c188b0d73c1 100644 (file)
@@ -159,7 +159,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                        $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA];
 
                        // Debug message
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)');
                } else {
                        // Debug message
                        /* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': packageContent=' . print_r($packageContent, TRUE) . ',chunks='.print_r($chunks, TRUE));
@@ -187,11 +187,18 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
         */
        public function handlePendingData () {
                // Debug output
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
 
                // Assert on condition
                assert(!$this->isPendingDataEmpty());
 
+               // No markers set?
+               if (!$this->ifStartEndMarkersSet($this->pendingData)) {
+                       // This will cause an assertition in next call, so simply wait for more data
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...');
+                       return;
+               } // END - if
+
                // Init fake array
                $packageContent = array(
                        BaseRawDataHandler::PACKAGE_RAW_DATA   => $this->getInputStreamInstance()->streamData($this->pendingData),
@@ -202,7 +209,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                $this->pendingData = '';
 
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
 
                // Make sure last CHUNK_SEPARATOR is not there
                if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
@@ -218,7 +225,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
 
                // Add all chunks because the last final chunk is found
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Going to add ' . count($chunks) . ' to chunk handler ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Going to add ' . count($chunks) . ' to chunk handler ...');
                $this->getHandlerInstance()->addAllChunksWithFinal($chunks);
        }
 }