我最近使用mfc的http协议向服务端发送文件,使用post请求方法,但是报头一直不正确,用抓包抓出来看也没看出来个所以然,头疼啊,对于传送文件头部哪些信息是必须的,最好有个例子啊?

解决方案 »

  1.   

       if( post == NULL )
    {
            SendString(sock,"GET ");
    strcpy(headerSend, "GET ");
    }
        else 
    {
    SendString(sock,"POST ");
    strcpy(headerSend, "POST ");
    }
        SendString(sock,request);    SendString(sock," HTTP/1.0\r\n");    SendString(sock,"Accept: image/gif, image/x-xbitmap,"
            " image/jpeg, image/pjpeg, application/vnd.ms-excel,"
            " application/msword, application/vnd.ms-powerpoint,"
            " */*\r\n");    SendString(sock,"Accept-Language: en-us\r\n");    SendString(sock,"Accept-Encoding: gzip, deflate\r\n");    SendString(sock,"User-Agent: Mozilla/4.0\r\n");    if(postLength)
        {
            wsprintf(buffer,"Content-Length: %ld\r\n",postLength);
            SendString(sock,buffer);
        }

        SendString(sock,"Host: ");    SendString(sock,host);    SendString(sock,"\r\n");