参数说明:
pInput :in ,将要编码的buffer缓冲区
nInLen:in,将要编码的buffer缓冲区长度
pOutput:out,编码把数据保存到输出buffer中
nOutLen:out,编码后输出缓冲区长度
bool Http_Chunked_Encoding(char*pInput,int nInLen,char*pOutput,int & nOutLen)
{
char szHeader[20];
int nLen = 0;
if(!pInput || ! pOutput || nInLen == 0) //check valid
return false;
sprintf(szHeader,"%x\r\n",nInLen); //chunked body len
nLen = strlen(szHeader); //header len
memcpy(pOutput,szHeader,nLen); //header
nOutLen += nLen;
memcpy(pOutput+nOutLen,pInput,nInLen); //body
nOutLen += nInLen;
memcpy(pOutput+nOutLen,"\r\n",2*sizeof(char)); //tailer
nOutLen += 2*sizeof(char); //total len
return true;
}