aboutsummaryrefslogtreecommitdiffstats
path: root/vbench/src/vbench/test/simple_http_result_handler.cpp
blob: 0a3b952fa6b1c70a2b70ca23794327dc30bff73d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "simple_http_result_handler.h"

namespace vbench {

using WritableMemory = vespalib::WritableMemory;

SimpleHttpResultHandler::SimpleHttpResultHandler()
    : _headers(),
      _content(),
      _failures()
{
}

SimpleHttpResultHandler::~SimpleHttpResultHandler() {}

void
SimpleHttpResultHandler::handleHeader(const string &name, const string &value)
{
    _headers.push_back(std::make_pair(name, value));
}

void
SimpleHttpResultHandler::handleContent(const Memory &data)
{
    WritableMemory wm = _content.reserve(data.size);
    memcpy(wm.data, data.data, data.size);
    _content.commit(data.size);
}

void
SimpleHttpResultHandler::handleFailure(const string &reason)
{
    _failures.push_back(reason);
}

} // namespace vbench