This function will 'unchunk' your HTTP data - In VB6, but you'll get the idea (really OLD CODE)
Private Function UnChunk(Indata As String) As String
If InStr(LCase(Indata), "transfer-encoding:") = 0 And InStr(LCase(Indata), "chunked") = 0 Then
'not chunked, so return the input
UnChunk = Indata
Exit Function
End If
'can't let this crash
On Error GoTo returnInData
Dim crlfstart As Long
Dim crlfend As Long
Dim chunksize As Long
'first, get header, which ends with 2 line feeds
crlfstart = InStr(Indata, vbCrLf & vbCrLf)
If crlfstart = 0 Then
'invalid http
UnChunk = Indata
Exit Function
End If
UnChunk = Left(Indata, crlfstart + 2)
'start looking for vbCrLf
crlfstart = InStr(crlfstart + 2, Indata, vbCrLf)
Do While crlfstart > 0
'find the next vbCrLf
crlfend = InStr(crlfstart + 1, Indata, vbCrLf)
If crlfend > crlfstart And crlfend - crlfstart < 10 Then
'convert the HEX string to the chunksize
chunksize = Val("&h" & Mid(Indata, crlfstart + 2, crlfend - (crlfstart + 2)))
'by spec, if 0 then no more data
If chunksize > 0 Then
'there's more data
'this should be unnecessary, but one more test
If Mid(Indata, crlfend + 2 + chunksize, 2) = vbCrLf Then
UnChunk = UnChunk & Mid(Indata, crlfend + 2, chunksize)
Else
'oops, failed
Exit Do
End If
Else
'there's no more data so return what we have
Exit Function
End If
End If
'look again
crlfstart = InStr(crlfstart + 1, Indata, vbCrLf)
Loop
'just in case this fails, return the input data
returnInData:
UnChunk = Indata
End Function