11#include " GzipDecoder.h"
22
3+ #if !ASYNC_HTTP_ENABLE_GZIP_DECODE
4+
5+ #include < string.h>
6+
7+ GzipDecoder::GzipDecoder ()
8+ : _state(State::kError ), _headerStage(HeaderStage::kFixed10 ), _error(" Gzip decode disabled" ), _fixedLen(0 ),
9+ _flags(0 ), _extraLenRead(0 ), _extraRemaining(0 ), _needName(false ), _needComment(false ), _needHcrc(false ),
10+ _trailerLen(0 ), _dict(nullptr ), _dictOfs(0 ), _decomp(nullptr ) {
11+ memset (_fixed, 0 , sizeof (_fixed));
12+ memset (_extraLenBytes, 0 , sizeof (_extraLenBytes));
13+ memset (_trailer, 0 , sizeof (_trailer));
14+ }
15+
16+ GzipDecoder::~GzipDecoder () {}
17+
18+ void GzipDecoder::reset () {}
19+
20+ bool GzipDecoder::begin () {
21+ return false ;
22+ }
23+
24+ GzipDecoder::Result GzipDecoder::write (const uint8_t * in, size_t inLen, size_t * inConsumed, const uint8_t ** outPtr,
25+ size_t * outLen, bool hasMoreInput) {
26+ (void )in;
27+ (void )inLen;
28+ (void )hasMoreInput;
29+ if (inConsumed)
30+ *inConsumed = 0 ;
31+ if (outPtr)
32+ *outPtr = nullptr ;
33+ if (outLen)
34+ *outLen = 0 ;
35+ _error = " Gzip decode disabled (build with -DASYNC_HTTP_ENABLE_GZIP_DECODE=1)" ;
36+ return Result::kError ;
37+ }
38+
39+ GzipDecoder::Result GzipDecoder::finish (const uint8_t ** outPtr, size_t * outLen) {
40+ if (outPtr)
41+ *outPtr = nullptr ;
42+ if (outLen)
43+ *outLen = 0 ;
44+ _error = " Gzip decode disabled (build with -DASYNC_HTTP_ENABLE_GZIP_DECODE=1)" ;
45+ return Result::kError ;
46+ }
47+
48+ bool GzipDecoder::isDone () const {
49+ return false ;
50+ }
51+
52+ const char * GzipDecoder::lastError () const {
53+ return _error ? _error : " " ;
54+ }
55+
56+ #else
57+
358#include < stdlib.h>
459#include < string.h>
560
@@ -18,9 +73,10 @@ static constexpr uint8_t kGzipFlagExtra = 0x04;
1873static constexpr uint8_t kGzipFlagName = 0x08 ;
1974static constexpr uint8_t kGzipFlagComment = 0x10 ;
2075
21- GzipDecoder::GzipDecoder () : _state(State::kHeader ), _headerStage(HeaderStage::kFixed10 ), _error(nullptr ), _fixedLen(0 ),
22- _flags(0 ), _extraLenRead(0 ), _extraRemaining(0 ), _needName(false ), _needComment(false ),
23- _needHcrc(false ), _trailerLen(0 ), _dict(nullptr ), _dictOfs(0 ), _decomp(nullptr ) {
76+ GzipDecoder::GzipDecoder ()
77+ : _state(State::kHeader ), _headerStage(HeaderStage::kFixed10 ), _error(nullptr ), _fixedLen(0 ), _flags(0 ),
78+ _extraLenRead(0 ), _extraRemaining(0 ), _needName(false ), _needComment(false ), _needHcrc(false ), _trailerLen(0 ),
79+ _dict(nullptr ), _dictOfs(0 ), _decomp(nullptr ) {
2480 memset (_fixed, 0 , sizeof (_fixed));
2581 memset (_extraLenBytes, 0 , sizeof (_extraLenBytes));
2682 memset (_trailer, 0 , sizeof (_trailer));
@@ -352,3 +408,5 @@ GzipDecoder::Result GzipDecoder::finish(const uint8_t** outPtr, size_t* outLen)
352408
353409 return r;
354410}
411+
412+ #endif // ASYNC_HTTP_ENABLE_GZIP_DECODE
0 commit comments