summaryrefslogtreecommitdiff
path: root/src/HttpHeader.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-03-05 12:31:57 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-03-05 12:31:57 +0000
commitba7f9f765794bc197750253f07211c66afdd69e5 (patch)
tree5b6dacc204d1ef6f3c2d19416d68524e180f98da /src/HttpHeader.cc
parentcc24f7cdf816a4e127efeaf9b74146e1296467c9 (diff)
2007-03-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/HttpHeader.h (Range.h): New include. (status): New variable. (HttpHeader): Initialized status with 0. (getStatus): New function. (setStatus): New function. (getRange): New function. (HttpHeaderHandle): New function. * src/HttpHeader.cc (getRange): New function. * src/Request.h (RequestWeakHandle): New definition. * src/HttpConnection.h (HttpConnectionHandle): New type definition. * src/HttpConnection.cc (receiveResponse): Set HTTP status to headers. * src/main.cc (showUsage): Fixed typo. * src/Segment.h (SegmentHandle): New type definition. * src/BitfieldMan.h (getMissingUnusedLength): New function. * src/BitfieldMan.cc (getMissingUnusedLength): New function.
Diffstat (limited to 'src/HttpHeader.cc')
-rw-r--r--src/HttpHeader.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc
index b9f97f16..adf74ae3 100644
--- a/src/HttpHeader.cc
+++ b/src/HttpHeader.cc
@@ -73,3 +73,23 @@ long long int HttpHeader::getFirstAsLLInt(const string& name) const {
return strtoll(value.c_str(), NULL, 10);
}
}
+
+RangeHandle HttpHeader::getRange() const
+{
+ string rangeStr = getFirst("Range");
+ if(rangeStr == "") {
+ return 0;
+ }
+ pair<string, string> rangePair;
+ Util::split(rangePair, rangeStr, '/');
+ pair<string, string> startEndBytePair;
+ Util::split(startEndBytePair, rangePair.first, '-');
+
+ int64_t startByte = STRTOLL(startEndBytePair.first.c_str());
+ int64_t endByte = STRTOLL(startEndBytePair.second.c_str());
+ int64_t contentLength = STRTOLL(rangePair.second.c_str());
+
+ RangeHandle range = new Range(startByte, endByte, contentLength);
+
+ return range;
+}