2001-05-11 21:04:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-05-11 21:04:09 +00:00
|
|
|
|
|
|
|
#ifndef nsHttpChunkedDecoder_h__
|
|
|
|
#define nsHttpChunkedDecoder_h__
|
|
|
|
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsString.h"
|
2001-09-26 23:30:28 +00:00
|
|
|
#include "nsHttpHeaderArray.h"
|
2001-05-11 21:04:09 +00:00
|
|
|
|
2014-01-07 22:05:56 +00:00
|
|
|
namespace mozilla { namespace net {
|
|
|
|
|
2001-05-11 21:04:09 +00:00
|
|
|
class nsHttpChunkedDecoder
|
|
|
|
{
|
|
|
|
public:
|
2012-07-30 14:20:58 +00:00
|
|
|
nsHttpChunkedDecoder() : mTrailers(nullptr)
|
2001-09-26 23:30:28 +00:00
|
|
|
, mChunkRemaining(0)
|
2011-10-17 14:59:28 +00:00
|
|
|
, mReachedEOF(false)
|
|
|
|
, mWaitEOF(false) {}
|
2001-09-26 23:30:28 +00:00
|
|
|
~nsHttpChunkedDecoder() { delete mTrailers; }
|
2001-05-11 21:04:09 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool ReachedEOF() { return mReachedEOF; }
|
2001-05-11 21:04:09 +00:00
|
|
|
|
2001-09-26 23:30:28 +00:00
|
|
|
// called by the transaction to handle chunked content.
|
2001-05-11 21:04:09 +00:00
|
|
|
nsresult HandleChunkedContent(char *buf,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count,
|
|
|
|
uint32_t *contentRead,
|
|
|
|
uint32_t *contentRemaining);
|
2001-09-26 23:30:28 +00:00
|
|
|
|
|
|
|
nsHttpHeaderArray *Trailers() { return mTrailers; }
|
|
|
|
|
|
|
|
nsHttpHeaderArray *TakeTrailers() { nsHttpHeaderArray *h = mTrailers;
|
2012-07-30 14:20:58 +00:00
|
|
|
mTrailers = nullptr;
|
2001-09-26 23:30:28 +00:00
|
|
|
return h; }
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t GetChunkRemaining() { return mChunkRemaining; }
|
2012-04-09 14:21:17 +00:00
|
|
|
|
2001-05-11 21:04:09 +00:00
|
|
|
private:
|
|
|
|
nsresult ParseChunkRemaining(char *buf,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count,
|
|
|
|
uint32_t *countRead);
|
2001-05-11 21:04:09 +00:00
|
|
|
|
|
|
|
private:
|
2001-09-26 23:30:28 +00:00
|
|
|
nsHttpHeaderArray *mTrailers;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mChunkRemaining;
|
2001-09-26 23:30:28 +00:00
|
|
|
nsCString mLineBuf; // may hold a partial line
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mReachedEOF;
|
|
|
|
bool mWaitEOF;
|
2001-05-11 21:04:09 +00:00
|
|
|
};
|
|
|
|
|
2014-01-07 22:05:56 +00:00
|
|
|
}} // namespace mozilla::net
|
|
|
|
|
2001-05-11 21:04:09 +00:00
|
|
|
#endif
|