00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "httpEntityTag.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 HTTPEntityTag::
00026 HTTPEntityTag(const string &text) {
00027 _weak = false;
00028
00029 size_t p = 0;
00030 if (text.length() >= 2) {
00031 string sub = text.substr(0, 2);
00032 if (sub == "W/" || sub == "w/") {
00033 _weak = true;
00034 p = 2;
00035 }
00036 }
00037
00038
00039 bool quoted = false;
00040 if (p < text.length() && text[p] == '"') {
00041 quoted = true;
00042 p++;
00043 }
00044 while (p < text.length() && !(quoted && text[p] == '"')) {
00045 if (text[p] == '\\') {
00046 p++;
00047 }
00048 _tag += text[p];
00049 p++;
00050 }
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060 string HTTPEntityTag::
00061 get_string() const {
00062 ostringstream result;
00063 if (_weak) {
00064 result << "W/";
00065 }
00066 result << '"';
00067
00068 for (string::const_iterator ti = _tag.begin(); ti != _tag.end(); ++ti) {
00069 switch (*ti) {
00070 case '"':
00071 case '\\':
00072 result << '\\';
00073
00074
00075 default:
00076 result << (*ti);
00077 }
00078 }
00079
00080 result << '"';
00081
00082 return result.str();
00083 }