Android-cuttlefish cvd tool
zip_over_ranges.h
Go to the documentation of this file.
1//
2// Copyright (C) 2026 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include <stdint.h>
19
20#include <map>
21#include <memory>
22#include <string>
23
26
27namespace cuttlefish {
28
29// Serves one archive over HTTP range requests, as an object store does.
31 public:
33 const std::map<std::string, std::string>& contents,
34 bool serve_ranges = true, bool reject_head = false);
35
37
38 uint64_t Size() const { return data_.size(); }
39 bool RangeRequestMade() const { return *ranged_; }
40 int HeadRequests() const { return *heads_; }
41
42 private:
43 ZipOverRanges(std::string data, bool serve_ranges, bool reject_head);
44
45 std::string data_;
48 std::shared_ptr<bool> ranged_;
49 std::shared_ptr<int> heads_;
50};
51
52} // namespace cuttlefish
Definition: zip_over_ranges.h:30
HttpResponse< std::string > operator()(const HttpRequest &request)
Definition: zip_over_ranges.cc:57
uint64_t Size() const
Definition: zip_over_ranges.h:38
bool RangeRequestMade() const
Definition: zip_over_ranges.h:39
static Result< ZipOverRanges > Create(const std::map< std::string, std::string > &contents, bool serve_ranges=true, bool reject_head=false)
Definition: zip_over_ranges.cc:40
ZipOverRanges(std::string data, bool serve_ranges, bool reject_head)
Definition: zip_over_ranges.cc:109
bool serve_ranges_
Definition: zip_over_ranges.h:46
std::shared_ptr< bool > ranged_
Definition: zip_over_ranges.h:48
std::shared_ptr< int > heads_
Definition: zip_over_ranges.h:49
bool reject_head_
Definition: zip_over_ranges.h:47
std::string data_
Definition: zip_over_ranges.h:45
int HeadRequests() const
Definition: zip_over_ranges.h:40
char data[Size]
Definition: incremental_server.cpp:1
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
Definition: http_client.h:93
Definition: http_client.h:42