aboutsummaryrefslogtreecommitdiff
path: root/include/curlheadercontainer.h
blob: e7f6e92fe60170cf425a297cfdbc7f9a66417685 (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
39
40
#ifndef NEWSBOAT_CURLHEADERCONTAINER_H_
#define NEWSBOAT_CURLHEADERCONTAINER_H_

#include <memory>
#include <string>
#include <vector>

#include "curlhandle.h"

namespace newsboat {

class CurlHeaderContainer {
public:
	// Registration is cleaned up on destruction
	static std::unique_ptr<CurlHeaderContainer> register_header_handler(
		CurlHandle& curlHandle);

	const std::vector<std::string>& get_header_lines() const;
	std::vector<std::string> get_header_lines(const std::string& key) const;
	~CurlHeaderContainer();

protected:
	explicit CurlHeaderContainer(CurlHandle& curlHandle);
	void handle_header(const std::string& line);

	CurlHeaderContainer(const CurlHeaderContainer&) = delete;
	CurlHeaderContainer(CurlHeaderContainer&&) = delete;
	CurlHeaderContainer& operator=(const CurlHeaderContainer&) = delete;
	CurlHeaderContainer& operator=(CurlHeaderContainer&&) = delete;

private:
	static size_t handle_headers(char* buffer, size_t size, size_t nitems, void* data);

	CurlHandle& mCurlHandle;
	std::vector<std::string> mHeaderLines;
};

} // namespace newsboat

#endif /* NEWSBOAT_CURLHEADERCONTAINER_H_ */