2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
#include "HttpHeader.h"
|
2011-01-19 15:25:01 +00:00
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2011-01-19 15:25:01 +00:00
|
|
|
#include "Range.h"
|
2011-11-02 15:31:27 +00:00
|
|
|
#include "DlAbortEx.h"
|
2011-01-19 15:25:01 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
class HttpHeaderTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(HttpHeaderTest);
|
|
|
|
CPPUNIT_TEST(testGetRange);
|
2011-11-11 13:50:18 +00:00
|
|
|
CPPUNIT_TEST(testFindAll);
|
2008-07-18 15:20:52 +00:00
|
|
|
CPPUNIT_TEST(testClearField);
|
2012-04-08 10:00:07 +00:00
|
|
|
CPPUNIT_TEST(testFieldContains);
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
2012-09-23 11:59:34 +00:00
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
public:
|
|
|
|
void testGetRange();
|
2011-11-11 13:50:18 +00:00
|
|
|
void testFindAll();
|
2008-07-18 15:20:52 +00:00
|
|
|
void testClearField();
|
2012-04-08 10:00:07 +00:00
|
|
|
void testFieldContains();
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( HttpHeaderTest );
|
|
|
|
|
|
|
|
void HttpHeaderTest::testGetRange()
|
|
|
|
{
|
2008-03-15 04:25:55 +00:00
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE,
|
2010-01-05 16:01:46 +00:00
|
|
|
"9223372036854775800-9223372036854775801/9223372036854775807");
|
2012-09-23 11:59:34 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2008-03-15 04:25:55 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775800LL, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775801LL, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775807LL, range.entityLength);
|
2008-03-15 04:25:55 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE,
|
2010-01-05 16:01:46 +00:00
|
|
|
"9223372036854775800-9223372036854775801/9223372036854775807");
|
2012-09-23 11:59:34 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2008-03-15 04:25:55 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775800LL, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775801LL, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775807LL, range.entityLength);
|
2008-03-15 04:25:55 +00:00
|
|
|
}
|
2010-10-31 07:56:01 +00:00
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes */1024");
|
2010-10-31 07:56:01 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2010-10-31 07:56:01 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.entityLength);
|
2010-10-31 07:56:01 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes 0-9/*");
|
2010-10-31 07:56:01 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2010-10-31 07:56:01 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.entityLength);
|
2010-10-31 07:56:01 +00:00
|
|
|
}
|
2011-11-02 15:31:27 +00:00
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes */*");
|
2011-11-02 15:31:27 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2011-11-02 15:31:27 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.entityLength);
|
2011-11-02 15:31:27 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes 0");
|
2011-11-02 15:31:27 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2011-11-02 15:31:27 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.entityLength);
|
2011-11-02 15:31:27 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes 0/");
|
2011-11-02 15:31:27 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
Range range = httpHeader.getRange();
|
2011-11-02 15:31:27 +00:00
|
|
|
|
2012-09-30 08:30:35 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.startByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.endByte);
|
|
|
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, range.entityLength);
|
2011-11-02 15:31:27 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes 0-/3");
|
2011-11-02 15:31:27 +00:00
|
|
|
try {
|
|
|
|
httpHeader.getRange();
|
|
|
|
CPPUNIT_FAIL("Exception must be thrown");
|
|
|
|
} catch(const DlAbortEx& e) {
|
|
|
|
// success
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
HttpHeader httpHeader;
|
2012-09-23 11:59:34 +00:00
|
|
|
httpHeader.put(HttpHeader::CONTENT_RANGE, "bytes -0/3");
|
2011-11-02 15:31:27 +00:00
|
|
|
try {
|
|
|
|
httpHeader.getRange();
|
|
|
|
CPPUNIT_FAIL("Exception must be thrown");
|
|
|
|
} catch(const DlAbortEx& e) {
|
|
|
|
// success
|
|
|
|
}
|
|
|
|
}
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2011-11-11 13:50:18 +00:00
|
|
|
void HttpHeaderTest::testFindAll()
|
2008-05-08 11:39:37 +00:00
|
|
|
{
|
|
|
|
HttpHeader h;
|
2012-09-23 11:59:34 +00:00
|
|
|
h.put(HttpHeader::LINK, "100");
|
|
|
|
h.put(HttpHeader::LINK, "101");
|
|
|
|
h.put(HttpHeader::CONNECTION, "200");
|
|
|
|
|
|
|
|
std::vector<std::string> r(h.findAll(HttpHeader::LINK));
|
2008-05-08 11:39:37 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((size_t)2, r.size());
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("100"), r[0]);
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("101"), r[1]);
|
|
|
|
}
|
|
|
|
|
2008-07-18 15:20:52 +00:00
|
|
|
void HttpHeaderTest::testClearField()
|
|
|
|
{
|
|
|
|
HttpHeader h;
|
2010-11-15 12:52:03 +00:00
|
|
|
h.setStatusCode(200);
|
2012-09-23 12:46:01 +00:00
|
|
|
h.setVersion("HTTP/1.1");
|
2012-09-23 11:59:34 +00:00
|
|
|
h.put(HttpHeader::LINK, "Bar");
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("Bar"), h.find(HttpHeader::LINK));
|
2008-07-18 15:20:52 +00:00
|
|
|
|
|
|
|
h.clearField();
|
|
|
|
|
2012-09-23 11:59:34 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string(""), h.find(HttpHeader::LINK));
|
2010-11-15 12:52:03 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(200, h.getStatusCode());
|
2012-09-23 12:46:01 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1"), h.getVersion());
|
2008-07-18 15:20:52 +00:00
|
|
|
}
|
|
|
|
|
2012-04-08 10:00:07 +00:00
|
|
|
void HttpHeaderTest::testFieldContains()
|
|
|
|
{
|
|
|
|
HttpHeader h;
|
2012-09-23 11:59:34 +00:00
|
|
|
h.put(HttpHeader::CONNECTION, "Keep-Alive, Upgrade");
|
|
|
|
h.put(HttpHeader::UPGRADE, "WebSocket");
|
|
|
|
h.put(HttpHeader::SEC_WEBSOCKET_VERSION, "13");
|
|
|
|
h.put(HttpHeader::SEC_WEBSOCKET_VERSION, "8, 7");
|
|
|
|
CPPUNIT_ASSERT(h.fieldContains(HttpHeader::CONNECTION, "upgrade"));
|
|
|
|
CPPUNIT_ASSERT(h.fieldContains(HttpHeader::CONNECTION, "keep-alive"));
|
|
|
|
CPPUNIT_ASSERT(!h.fieldContains(HttpHeader::CONNECTION, "close"));
|
|
|
|
CPPUNIT_ASSERT(h.fieldContains(HttpHeader::UPGRADE, "websocket"));
|
|
|
|
CPPUNIT_ASSERT(!h.fieldContains(HttpHeader::UPGRADE, "spdy"));
|
|
|
|
CPPUNIT_ASSERT(h.fieldContains(HttpHeader::SEC_WEBSOCKET_VERSION, "13"));
|
|
|
|
CPPUNIT_ASSERT(h.fieldContains(HttpHeader::SEC_WEBSOCKET_VERSION, "8"));
|
|
|
|
CPPUNIT_ASSERT(!h.fieldContains(HttpHeader::SEC_WEBSOCKET_VERSION, "6"));
|
2012-04-08 10:00:07 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|