Commit 6a8ddb34 authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: dash: don't store http reply as member

parent cba9fffa
......@@ -34,8 +34,7 @@ using namespace dash::http;
HTTPConnection::HTTPConnection (stream_t *stream) :
IHTTPConnection (stream),
peekBufferLen (0),
contentLength (0)
peekBufferLen (0)
{
this->peekBuffer = new uint8_t[PEEKBUFFER];
}
......@@ -84,12 +83,15 @@ std::string HTTPConnection::getRequestHeader (const Chunk *chunk) const
bool HTTPConnection::init (Chunk *chunk)
{
if (IHTTPConnection::init(chunk))
return parseHeader();
{
HeaderReply reply;
return parseHeader(&reply);
}
else
return false;
}
bool HTTPConnection::parseHeader ()
bool HTTPConnection::parseHeader (HeaderReply *reply)
{
std::string line = this->readLine();
......@@ -99,7 +101,7 @@ bool HTTPConnection::parseHeader ()
while(line.compare("\r\n"))
{
if(!strncasecmp(line.c_str(), "Content-Length", 14))
this->contentLength = atoi(line.substr(15,line.size()).c_str());
reply->contentLength = atoi(line.substr(15,line.size()).c_str());
line = this->readLine();
......
......@@ -49,12 +49,18 @@ namespace dash
virtual int peek (const uint8_t **pp_peek, size_t i_peek);
protected:
class HeaderReply
{
public:
int contentLength;
};
uint8_t *peekBuffer;
size_t peekBufferLen;
int contentLength;
virtual bool send (const std::string& data);
bool parseHeader ();
bool parseHeader (HeaderReply *);
std::string readLine ();
virtual std::string getRequestHeader(const Chunk *chunk) const; /* reimpl */
};
......
......@@ -130,18 +130,19 @@ bool PersistentConnection::addChunk (Chunk *chunk)
}
bool PersistentConnection::initChunk (Chunk *chunk)
{
if(this->parseHeader())
HeaderReply reply;
if(parseHeader(&reply))
{
chunk->setLength(this->contentLength);
chunk->setLength(reply.contentLength);
return true;
}
if(!this->reconnect(chunk))
if(!reconnect(chunk))
return false;
if(this->parseHeader())
if(parseHeader(&reply))
{
chunk->setLength(this->contentLength);
chunk->setLength(reply.contentLength);
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment