michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsHttpChunkedDecoder_h__ michael@0: #define nsHttpChunkedDecoder_h__ michael@0: michael@0: #include "nsError.h" michael@0: #include "nsString.h" michael@0: #include "nsHttpHeaderArray.h" michael@0: michael@0: namespace mozilla { namespace net { michael@0: michael@0: class nsHttpChunkedDecoder michael@0: { michael@0: public: michael@0: nsHttpChunkedDecoder() : mTrailers(nullptr) michael@0: , mChunkRemaining(0) michael@0: , mReachedEOF(false) michael@0: , mWaitEOF(false) {} michael@0: ~nsHttpChunkedDecoder() { delete mTrailers; } michael@0: michael@0: bool ReachedEOF() { return mReachedEOF; } michael@0: michael@0: // called by the transaction to handle chunked content. michael@0: nsresult HandleChunkedContent(char *buf, michael@0: uint32_t count, michael@0: uint32_t *contentRead, michael@0: uint32_t *contentRemaining); michael@0: michael@0: nsHttpHeaderArray *Trailers() { return mTrailers; } michael@0: michael@0: nsHttpHeaderArray *TakeTrailers() { nsHttpHeaderArray *h = mTrailers; michael@0: mTrailers = nullptr; michael@0: return h; } michael@0: michael@0: uint32_t GetChunkRemaining() { return mChunkRemaining; } michael@0: michael@0: private: michael@0: nsresult ParseChunkRemaining(char *buf, michael@0: uint32_t count, michael@0: uint32_t *countRead); michael@0: michael@0: private: michael@0: nsHttpHeaderArray *mTrailers; michael@0: uint32_t mChunkRemaining; michael@0: nsCString mLineBuf; // may hold a partial line michael@0: bool mReachedEOF; michael@0: bool mWaitEOF; michael@0: }; michael@0: michael@0: }} // namespace mozilla::net michael@0: michael@0: #endif