MCPcopy Create free account
hub / github.com/apache/mesos / _attachContainerOutput

Method _attachContainerOutput

src/slave/http.cpp:4350–4451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4348
4349
4350Future<Response> Http::_attachContainerOutput(
4351 const mesos::agent::Call& call,
4352 const RequestMediaTypes& mediaTypes) const
4353{
4354 const ContainerID& containerId =
4355 call.attach_container_output().container_id();
4356
4357 return slave->containerizer->attach(containerId)
4358 .then([call, mediaTypes](Connection connection)
4359 -> Future<Response> {
4360 Request request;
4361 request.method = "POST";
4362 request.headers = {{"Accept", stringify(mediaTypes.accept)},
4363 {"Content-Type", stringify(mediaTypes.content)}};
4364
4365 // If a client sets the 'Accept' header expecting a streaming response,
4366 // `messageAccept` would always be set and we use it as the value of
4367 // 'Message-Accept' header.
4368 if (streamingMediaType(mediaTypes.accept)) {
4369 CHECK_SOME(mediaTypes.messageAccept);
4370 request.headers[MESSAGE_ACCEPT] =
4371 stringify(mediaTypes.messageAccept.get());
4372 }
4373
4374 // The 'HOST' header must be EMPTY for non Internet addresses.
4375 // TODO(vinod): Instead of setting domain to empty string (which results
4376 // in an empty HOST header), add a new URL constructor that doesn't
4377 // require domain or IP.
4378 request.url.domain = "";
4379
4380 // NOTE: The path is currently ignored by the switch board.
4381 request.url.path = "/";
4382
4383 request.type = Request::BODY;
4384 request.body = serialize(mediaTypes.content, call);
4385
4386 // We capture `connection` here to ensure that it doesn't go
4387 // out of scope until the `onAny` handler on `transform` is executed.
4388 return connection.send(request, true)
4389 .then([connection, mediaTypes](const Response& response)
4390 -> Future<Response> {
4391 if (response.status != OK().status) {
4392 return response;
4393 }
4394
4395 // Evolve the `ProcessIO` records in the Response body to v1
4396 // before sending them to the client.
4397 Pipe pipe;
4398 Pipe::Writer writer = pipe.writer();
4399
4400 OK ok;
4401 ok.headers = response.headers; // Reuse headers from response.
4402
4403 // If a client sets the 'Accept' header expecting a streaming
4404 // response, `messageAccept` would always be set and we use it
4405 // to deserialize/evolve messages in the streaming response.
4406 ContentType messageContentType = mediaTypes.accept;
4407 if (streamingMediaType(mediaTypes.accept)) {

Callers

nothing calls this directly

Calls 15

streamingMediaTypeFunction · 0.85
OKClass · 0.85
writerMethod · 0.80
readerMethod · 0.80
isDiscardedMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
sendMethod · 0.65
stringifyFunction · 0.50
serializeFunction · 0.50
bindFunction · 0.50
evolveFunction · 0.50

Tested by

no test coverage detected