Jump to content

Weird chunked transfer encoding problem


htzone

Recommended Posts

So, I'm using fsockopen/fgets to grab an xml file. The transfer encoding coming to me is chunked, so every so often there's a crap line in the middle of the file that I need to get rid of. Here's an example of the data:

 

<SomeXML/>blarg</SomeXML>
0fe8
<SomeOtherXML>blah</SomeOtherXML>
<MoreXML>zing</MoreXML>

 

Here's the relevant code, for now:

 

    while (!feof($fp)) { 
       if (strpos(fgets($fp), '<') === FALSE) { continue; }
       $response .= fgets($fp);
    } 

 

The strpos bit there does work - the HTTP headers don't show up when I use it - but the '0fe8' (and other similar values) still show. The weird thing is that the first occurrence of that value does get nixed (before the XML starts), but subsequent ones do not. Is this some new line/end of line thing? Could anyone shed some light on why this isn't working 100% of the time?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.