MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / httpContentEncodingFromHeader

Function httpContentEncodingFromHeader

Libraries/Http/HttpConnection.cpp:146–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146Result httpContentEncodingFromHeader(StringSpan headerValue, HttpContentEncoding& encoding)
147{
148 HttpStringIterator it(headerValue);
149 while (it.match(' ') or it.match('\t'))
150 {
151 if (not it.stepForward())
152 {
153 break;
154 }
155 }
156 const auto start = it;
157 while (not it.isAtEnd() and not it.match(' ') and not it.match('\t') and not it.match(','))
158 {
159 if (not it.stepForward())
160 {
161 break;
162 }
163 }
164 StringSpan token = HttpStringIterator::fromIterators(start, it, headerValue.getEncoding());
165 if (token.isEmpty() or HttpStringIterator::equalsIgnoreCase(token, "identity"))
166 {
167 encoding = HttpContentEncoding::Identity;
168 return Result(true);
169 }
170 if (HttpStringIterator::equalsIgnoreCase(token, "gzip"))
171 {
172 encoding = HttpContentEncoding::GZip;
173 return Result(true);
174 }
175 if (HttpStringIterator::equalsIgnoreCase(token, "deflate"))
176 {
177 encoding = HttpContentEncoding::Deflate;
178 return Result(true);
179 }
180 return Result::Error("HttpContentEncoding unsupported content encoding");
181}
182
183//-------------------------------------------------------------------------------------------------------
184// HttpMultipartWriter

Callers 1

Calls 6

isAtEndMethod · 0.80
ResultClass · 0.50
ErrorEnum · 0.50
matchMethod · 0.45
stepForwardMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected