Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/protocol/http/nsHttpChunkedDecoder.h
Line
Count
Source (jump to first uncovered line)
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 "nsAutoPtr.h"
10
#include "nsError.h"
11
#include "nsString.h"
12
#include "nsHttpHeaderArray.h"
13
14
namespace mozilla { namespace net {
15
16
class nsHttpChunkedDecoder
17
{
18
public:
19
    nsHttpChunkedDecoder() : mTrailers(nullptr)
20
                           , mChunkRemaining(0)
21
                           , mReachedEOF(false)
22
0
                           , mWaitEOF(false) {}
23
0
   ~nsHttpChunkedDecoder() { delete mTrailers; }
24
25
0
    bool ReachedEOF() { return mReachedEOF; }
26
27
    // called by the transaction to handle chunked content.
28
    MOZ_MUST_USE nsresult HandleChunkedContent(char *buf,
29
                                               uint32_t count,
30
                                               uint32_t *contentRead,
31
                                               uint32_t *contentRemaining);
32
33
0
    nsHttpHeaderArray *Trailers() { return mTrailers.get(); }
34
35
0
    nsHttpHeaderArray *TakeTrailers() { return mTrailers.forget(); }
36
37
0
    uint32_t GetChunkRemaining() { return mChunkRemaining; }
38
39
private:
40
    MOZ_MUST_USE nsresult ParseChunkRemaining(char *buf,
41
                                              uint32_t count,
42
                                              uint32_t *countRead);
43
44
private:
45
    nsAutoPtr<nsHttpHeaderArray>  mTrailers;
46
    uint32_t                      mChunkRemaining;
47
    nsCString                     mLineBuf; // may hold a partial line
48
    bool                          mReachedEOF;
49
    bool                          mWaitEOF;
50
};
51
52
} // namespace net
53
} // namespace mozilla
54
55
#endif