Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsHttpChunkedDecoder_h__ |
michael@0 | 7 | #define nsHttpChunkedDecoder_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsError.h" |
michael@0 | 10 | #include "nsString.h" |
michael@0 | 11 | #include "nsHttpHeaderArray.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { namespace net { |
michael@0 | 14 | |
michael@0 | 15 | class nsHttpChunkedDecoder |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | nsHttpChunkedDecoder() : mTrailers(nullptr) |
michael@0 | 19 | , mChunkRemaining(0) |
michael@0 | 20 | , mReachedEOF(false) |
michael@0 | 21 | , mWaitEOF(false) {} |
michael@0 | 22 | ~nsHttpChunkedDecoder() { delete mTrailers; } |
michael@0 | 23 | |
michael@0 | 24 | bool ReachedEOF() { return mReachedEOF; } |
michael@0 | 25 | |
michael@0 | 26 | // called by the transaction to handle chunked content. |
michael@0 | 27 | nsresult HandleChunkedContent(char *buf, |
michael@0 | 28 | uint32_t count, |
michael@0 | 29 | uint32_t *contentRead, |
michael@0 | 30 | uint32_t *contentRemaining); |
michael@0 | 31 | |
michael@0 | 32 | nsHttpHeaderArray *Trailers() { return mTrailers; } |
michael@0 | 33 | |
michael@0 | 34 | nsHttpHeaderArray *TakeTrailers() { nsHttpHeaderArray *h = mTrailers; |
michael@0 | 35 | mTrailers = nullptr; |
michael@0 | 36 | return h; } |
michael@0 | 37 | |
michael@0 | 38 | uint32_t GetChunkRemaining() { return mChunkRemaining; } |
michael@0 | 39 | |
michael@0 | 40 | private: |
michael@0 | 41 | nsresult ParseChunkRemaining(char *buf, |
michael@0 | 42 | uint32_t count, |
michael@0 | 43 | uint32_t *countRead); |
michael@0 | 44 | |
michael@0 | 45 | private: |
michael@0 | 46 | nsHttpHeaderArray *mTrailers; |
michael@0 | 47 | uint32_t mChunkRemaining; |
michael@0 | 48 | nsCString mLineBuf; // may hold a partial line |
michael@0 | 49 | bool mReachedEOF; |
michael@0 | 50 | bool mWaitEOF; |
michael@0 | 51 | }; |
michael@0 | 52 | |
michael@0 | 53 | }} // namespace mozilla::net |
michael@0 | 54 | |
michael@0 | 55 | #endif |