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; ...@@ -34,8 +34,7 @@ using namespace dash::http;
HTTPConnection::HTTPConnection (stream_t *stream) : HTTPConnection::HTTPConnection (stream_t *stream) :
IHTTPConnection (stream), IHTTPConnection (stream),
peekBufferLen (0), peekBufferLen (0)
contentLength (0)
{ {
this->peekBuffer = new uint8_t[PEEKBUFFER]; this->peekBuffer = new uint8_t[PEEKBUFFER];
} }
...@@ -84,12 +83,15 @@ std::string HTTPConnection::getRequestHeader (const Chunk *chunk) const ...@@ -84,12 +83,15 @@ std::string HTTPConnection::getRequestHeader (const Chunk *chunk) const
bool HTTPConnection::init (Chunk *chunk) bool HTTPConnection::init (Chunk *chunk)
{ {
if (IHTTPConnection::init(chunk)) if (IHTTPConnection::init(chunk))
return parseHeader(); {
HeaderReply reply;
return parseHeader(&reply);
}
else else
return false; return false;
} }
bool HTTPConnection::parseHeader () bool HTTPConnection::parseHeader (HeaderReply *reply)
{ {
std::string line = this->readLine(); std::string line = this->readLine();
...@@ -99,7 +101,7 @@ bool HTTPConnection::parseHeader () ...@@ -99,7 +101,7 @@ bool HTTPConnection::parseHeader ()
while(line.compare("\r\n")) while(line.compare("\r\n"))
{ {
if(!strncasecmp(line.c_str(), "Content-Length", 14)) 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(); line = this->readLine();
......
...@@ -49,12 +49,18 @@ namespace dash ...@@ -49,12 +49,18 @@ namespace dash
virtual int peek (const uint8_t **pp_peek, size_t i_peek); virtual int peek (const uint8_t **pp_peek, size_t i_peek);
protected: protected:
class HeaderReply
{
public:
int contentLength;
};
uint8_t *peekBuffer; uint8_t *peekBuffer;
size_t peekBufferLen; size_t peekBufferLen;
int contentLength;
virtual bool send (const std::string& data); virtual bool send (const std::string& data);
bool parseHeader (); bool parseHeader (HeaderReply *);
std::string readLine (); std::string readLine ();
virtual std::string getRequestHeader(const Chunk *chunk) const; /* reimpl */ virtual std::string getRequestHeader(const Chunk *chunk) const; /* reimpl */
}; };
......
...@@ -130,18 +130,19 @@ bool PersistentConnection::addChunk (Chunk *chunk) ...@@ -130,18 +130,19 @@ bool PersistentConnection::addChunk (Chunk *chunk)
} }
bool PersistentConnection::initChunk (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; return true;
} }
if(!this->reconnect(chunk)) if(!reconnect(chunk))
return false; return false;
if(this->parseHeader()) if(parseHeader(&reply))
{ {
chunk->setLength(this->contentLength); chunk->setLength(reply.contentLength);
return true; 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