MCPcopy Create free account
hub / github.com/boostorg/beast / testTrailerHeaders

Method testTrailerHeaders

test/beast/http/parser.cpp:331–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329 }
330
331 void
332 testTrailerHeaders()
333 {
334 // standard trailer not listed in `Trailer` fields
335 {
336 error_code ec;
337 parser_type<false> p;
338 p.eager(true);
339 p.put(
340 buf("HTTP/1.1 200 OK\r\n"
341 "Transfer-Encoding: chunked\r\n"
342 "\r\n"
343 "0\r\n"
344 "Content-Digest: 123\r\n"
345 "\r\n"),
346 ec);
347 BEAST_EXPECT(p.is_done());
348
349 // standard, not listed in Trailer
350 BEAST_EXPECT(! p.get().contains(field::content_digest));
351 }
352
353 // parser::merge_all_trailers(false);
354 {
355 error_code ec;
356 parser_type<false> p;
357 p.eager(true);
358 p.put(
359 buf("HTTP/1.1 200 OK\r\n"
360 "Transfer-Encoding: chunked\r\n"
361 "Trailer: Signature, X-Forwarded-For\r\n"
362 "\r\n"
363 "0\r\n"
364 "Content-Digest: 123\r\n"
365 "Signature: xyz\r\n"
366 "X-Forwarded-For: 203.0.113.195\r\n"
367 "\r\n"),
368 ec);
369 BEAST_EXPECT(p.is_done());
370
371 // standard, listed in Trailer
372 BEAST_EXPECT(p.get()[field::signature] == "xyz");
373
374 // standard, not listed in Trailer
375 BEAST_EXPECT(! p.get().contains(field::content_digest));
376 // non-standard, listed in Trailer
377 BEAST_EXPECT(! p.get().contains(field::x_forwarded_for));
378 }
379
380 // parser::merge_all_trailers(true);
381 {
382 error_code ec;
383 parser_type<false> p;
384 p.eager(true);
385 p.merge_all_trailers(true);
386 p.put(
387 buf("HTTP/1.1 200 OK\r\n"
388 "Transfer-Encoding: chunked\r\n"

Callers

nothing calls this directly

Calls 4

eagerMethod · 0.80
putMethod · 0.45
is_doneMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected