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
https://forums.phpfreaks.com/topic/162502-weird-chunked-transfer-encoding-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.