netwerk/protocol/http/nsHttpChunkedDecoder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/http/nsHttpChunkedDecoder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsHttpChunkedDecoder_h__
    1.10 +#define nsHttpChunkedDecoder_h__
    1.11 +
    1.12 +#include "nsError.h"
    1.13 +#include "nsString.h"
    1.14 +#include "nsHttpHeaderArray.h"
    1.15 +
    1.16 +namespace mozilla { namespace net {
    1.17 +
    1.18 +class nsHttpChunkedDecoder
    1.19 +{
    1.20 +public:
    1.21 +    nsHttpChunkedDecoder() : mTrailers(nullptr)
    1.22 +                           , mChunkRemaining(0)
    1.23 +                           , mReachedEOF(false)
    1.24 +                           , mWaitEOF(false) {}
    1.25 +   ~nsHttpChunkedDecoder() { delete mTrailers; }
    1.26 +
    1.27 +    bool ReachedEOF() { return mReachedEOF; }
    1.28 +
    1.29 +    // called by the transaction to handle chunked content.
    1.30 +    nsresult HandleChunkedContent(char *buf,
    1.31 +                                  uint32_t count,
    1.32 +                                  uint32_t *contentRead,
    1.33 +                                  uint32_t *contentRemaining);
    1.34 +
    1.35 +    nsHttpHeaderArray *Trailers() { return mTrailers; }
    1.36 +
    1.37 +    nsHttpHeaderArray *TakeTrailers() { nsHttpHeaderArray *h = mTrailers;
    1.38 +                                        mTrailers = nullptr;
    1.39 +                                        return h; }
    1.40 +
    1.41 +    uint32_t GetChunkRemaining() { return mChunkRemaining; }
    1.42 +
    1.43 +private:
    1.44 +    nsresult ParseChunkRemaining(char *buf,
    1.45 +                                 uint32_t count,
    1.46 +                                 uint32_t *countRead);
    1.47 +
    1.48 +private:
    1.49 +    nsHttpHeaderArray *mTrailers;
    1.50 +    uint32_t           mChunkRemaining;
    1.51 +    nsCString          mLineBuf; // may hold a partial line
    1.52 +    bool               mReachedEOF;
    1.53 +    bool               mWaitEOF;
    1.54 +};
    1.55 +
    1.56 +}} // namespace mozilla::net
    1.57 +
    1.58 +#endif

mercurial