Use HttpMime::reset instead of setting it separately to avoid forgetting to clear some variables in HttpMime::set function

This commit is contained in:
Ai Lin Chia 2018-02-02 15:06:22 +01:00
parent 8e5c6bf85d
commit 87f9ca70a1
2 changed files with 5 additions and 24 deletions

@ -43,6 +43,7 @@ HttpMime::HttpMime () {
memset(m_buf, 0, sizeof(m_buf));
m_mimeLen = 0;
m_contentEncoding = 0;
m_fakeCurrentTime = false;
reset();
}
@ -57,8 +58,9 @@ void HttpMime::reset ( ) {
m_nextLineStartPos = 0;
m_attributeStartPos = 0;
m_currentTime = time(NULL);
m_fakeCurrentTime = false;
if (!m_fakeCurrentTime) {
m_currentTime = time(NULL);
}
m_status = -1;
m_contentLen = -1;
@ -85,27 +87,7 @@ bool HttpMime::set ( const char *buf , int32_t bufLen , Url *url ) {
#ifdef _VALGRIND_
VALGRIND_CHECK_MEM_IS_DEFINED(buf,bufLen);
#endif
// reset some stuff
m_mime = NULL;
m_currentLine = NULL;
m_currentLineLen = 0;
m_valueStartPos = 0;
m_nextLineStartPos = 0;
m_attributeStartPos = 0;
if (!m_fakeCurrentTime) {
m_currentTime = time(NULL);
}
m_contentLen = -1;
m_content = NULL;
m_mimeLen = 0;
m_contentType = CT_HTML;
m_contentEncoding = ET_IDENTITY;
m_charset = NULL;
m_charsetLen = 0;
m_cookies.clear();
reset();
// at the very least we should have a "HTTP/x.x 404\[nc]"
if ( bufLen < 13 ) {

@ -314,7 +314,6 @@ void XmlDoc::reset ( ) {
m_synBuf.reset();
m_images.reset();
m_countTable.reset();
m_mime.reset();
m_tagRec.reset();
m_newTagBuf.reset();
m_dupList.reset();