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

Method doRelay

test/doc/http_examples.cpp:123–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 }
122
123 void
124 doRelay()
125 {
126 request<string_body> req;
127 req.version(11);
128 req.method_string("POST");
129 req.target("/");
130 req.insert(field::user_agent, "test");
131 req.body() = "Hello, world!";
132 req.prepare_payload();
133
134 test::stream ds{ioc_}, dsr{ioc_};
135 ds.connect(dsr);
136 dsr.read_size(3);
137 test::stream us{ioc_}, usr{ioc_};
138 us.connect(usr);
139 us.write_size(3);
140
141 error_code ec;
142 write(ds, req);
143 BEAST_EXPECTS(! ec, ec.message());
144 ds.close();
145
146 flat_buffer buffer;
147 relay<true>(us, dsr, buffer, ec,
148 [&](header<true, fields>& h, error_code& ev)
149 {
150 ev = {};
151 h.erase("Content-Length");
152 h.set("Transfer-Encoding", "chunked");
153 });
154 BEAST_EXPECTS(! ec, ec.message());
155 BEAST_EXPECT(equal_body<true>(
156 usr.str(), req.body()));
157 }
158
159 void
160 doReadStdStream()

Callers

nothing calls this directly

Calls 10

targetMethod · 0.80
bodyMethod · 0.80
read_sizeMethod · 0.80
write_sizeMethod · 0.80
messageMethod · 0.80
writeFunction · 0.50
versionMethod · 0.45
insertMethod · 0.45
closeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected