Changeset 24244 for titan/titan/sock.h


Ignore:
Timestamp:
10/12/13 18:29:18 (10 years ago)
Author:
nit
Message:

[titan] add gzip to gethtml

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/sock.h

    r24241 r24244  
    590590char* gethttpreal(char* host, char* page, int port, char* filename, char* auth, struct download* dnode, int redirect, char* header, long* clen, int timeout, int flag)
    591591{
    592         int sock = -1, ret = 0, count = 0, hret = 0, freeheader = 0;
     592        int sock = -1, ret = 0, count = 0, hret = 0, freeheader = 0, gzip = 0;
    593593        int headerlen = 0;
    594594        unsigned int len = 0, maxret = 0;
     
    726726                len = strtoul(contentlen, NULL, 10);
    727727        }
     728        if(filename == NULL && flag == 0 && ostrstr(tmpbuf, "Content-Type: application/x-gzip") != NULL)
     729                gzip = 1;
    728730
    729731        if(flag == 0) headerlen = 0;
     
    773775        if(fd != NULL) fclose(fd);
    774776        sockclose(&sock);
     777       
     778        if(gzip == 1)
     779        {
     780                int unzipret = 0, outlen = 0;
     781                char* outbuf = NULL;
     782               
     783                unzipret = ounzip(buf, count, &outbuf, &outlen, MINMALLOC * 100, 0);
     784                if(unzipret == 0 && outbuf != NULL)
     785                {
     786                        free(buf); buf = outbuf;
     787                        count = outlen;
     788                }
     789                else
     790                {
     791                        err("unzip http data");
     792                }
     793        }
    775794
    776795        if(filename == NULL)
Note: See TracChangeset for help on using the changeset viewer.