Changeset 1451


Ignore:
Timestamp:
May 19, 2009 8:37:02 AM (12 years ago)
Author:
gah
Message:
 
Location:
trunk/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpEncode.cc

    r1415 r1451  
    103103}
    104104
     105bool
     106Rappture::encoding::isGzipped(const char* buf, int size)
     107{
     108    if (buf == NULL) {
     109        return false;                   /* Really should let this segfault. */
     110    }
     111    return ((buf[0] == 0x1f)  && (buf[1] == 0x8b));
     112}
     113
    105114/**********************************************************************/
    106115// FUNCTION: Rappture::encoding::headerFlags()
     
    261270            size -= 14;
    262271            headerFlags |= (RPENC_B64 | RPENC_Z);
     272        } else if ((size > 13) && (strncmp(bytes, "@@RP-ENC:raw\n", 14) == 0)){
     273            bytes += 13;
     274            size -= 13;
    263275        }
    264276         if (headerFlags != 0) {
     
    281293        }
    282294    }
    283     if ((flags & (RPENC_B64 | RPENC_Z)) == 0) {
    284         return true;                /* No decode or decompress flags present. */
    285     }
    286295    if (outData.append(bytes, size) != (int)size) {
    287296        status.addError("can't append %d bytes to buffer", size);
    288297        return false;
    289298    }
    290     if (!outData.decode(status, flags)) {
    291         return false;
     299    if (flags & (RPENC_B64 | RPENC_Z)) {
     300        if (!outData.decode(status, flags)) {
     301            return false;
     302        }
    292303    }
    293304    buf.move(outData);
  • trunk/src/core/RpEncode.h

    r1384 r1451  
    3434bool isBinary(const char* buf, int size);
    3535bool isBase64(const char* buf, int size);
     36bool isGzipped(const char* buf, int size);
    3637unsigned int headerFlags(const char* buf, int size);
    3738bool encode(Rappture::Outcome &err, Rappture::Buffer& buf, unsigned int flags);
Note: See TracChangeset for help on using the changeset viewer.