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