Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7730511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:14:32+00:00 2026-06-01T06:14:32+00:00

After making a gzip deflate request in PHP, I receive the deflated string in

  • 0

After making a gzip deflate request in PHP, I receive the deflated string in offset chunks, which looks like the following

Example shortened greatly to show format:

00001B4E
¾”kŒj…Øæ’ìÑ«F1ìÊ`+ƒQì¹UÜjùJƒZ\µy¡ÓUžGr‡J&=KLËÙÍ~=ÍkR
0000102F
ñÞœÞôΑüo[¾”+’Ñ8#à»0±R-4VÕ’n›êˆÍ.MCŽ…ÏÖr¿3M—èßñ°r¡\+
00000000

I’m unable to inflate that presumably because of the chunked format. I can confirm the data is not corrupt after manually removing the offsets with a Hex editor and reading the gzip archive. I’m wondering if there’s a proper method to parse this chunked gzip deflated response into a readable string?

I might be able to split these offsets and join the data together in one string to call gzinflate, but it seems there must be an easier way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:14:33+00:00Added an answer on June 1, 2026 at 6:14 am

    The proper method to deflate a chunked response is roughly as follows:

    initialise string to hold result
    for each chunk {
      check that the stated chunk length equals the string length of the chunk
      append the chunk data to the result variable
    }
    

    Here’s a handy PHP function to do that for you (FIXED):

    function unchunk_string ($str) {
    
      // A string to hold the result
      $result = '';
    
      // Split input by CRLF
      $parts = explode("\r\n", $str);
    
      // These vars track the current chunk
      $chunkLen = 0;
      $thisChunk = '';
    
      // Loop the data
      while (($part = array_shift($parts)) !== NULL) {
        if ($chunkLen) {
          // Add the data to the string
          // Don't forget, the data might contain a literal CRLF
          $thisChunk .= $part."\r\n";
          if (strlen($thisChunk) == $chunkLen) {
            // Chunk is complete
            $result .= $thisChunk;
            $chunkLen = 0;
            $thisChunk = '';
          } else if (strlen($thisChunk) == $chunkLen + 2) {
            // Chunk is complete, remove trailing CRLF
            $result .= substr($thisChunk, 0, -2);
            $chunkLen = 0;
            $thisChunk = '';
          } else if (strlen($thisChunk) > $chunkLen) {
            // Data is malformed
            return FALSE;
          }
        } else {
          // If we are not in a chunk, get length of the new one
          if ($part === '') continue;
          if (!$chunkLen = hexdec($part)) break;
        }
      }
    
      // Return the decoded data of FALSE if it is incomplete
      return ($chunkLen) ? FALSE : $result;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my application after making it five calculations. That is, using 5
I've been getting an 'Invalid JSON' after making a jQuery AJAX Request. This request
After making an Asynchronous Call in C#, I would like to be able to
After making an auto complete text view once the user click the OK button(which
After making some changes in my models (eg. new field in a model and
After making a few modifications to a rails app I am tinkering on, railroad
I pushed my app to heroku after making sure it works fine in my
I am attempting to integrate an existing payment platform into my webshop. After making
On my site, users choose colors they want and after making their selections they
After seeing a previous post Making Applications programmed in .NET languages work on older

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.