File: SoapyHTTPUtils.hpp

package info (click to toggle)
soapyremote 0.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 504 kB
  • sloc: cpp: 6,740; makefile: 13
file content (42 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (2)
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
41
42
// Copyright (c) 2015-2015 Josh Blum
// SPDX-License-Identifier: BSL-1.0

#pragma once
#include "SoapyRemoteConfig.hpp"
#include <string>

class SOAPY_REMOTE_API SoapyHTTPHeader
{
public:

    //! Create an HTTP header given request/response line
    SoapyHTTPHeader(const std::string &line0);

    //! Add a key/value field to the header
    void addField(const std::string &key, const std::string &value);

    //! Done adding fields to the header
    void finalize(void);

    //! Create an HTTP from a received datagram
    SoapyHTTPHeader(const void *buff, const size_t length);

    //! Get the request/response line
    std::string getLine0(void) const;

    //! Read a field from the HTTP header (empty when missing)
    std::string getField(const std::string &key) const;

    const void *data(void) const
    {
        return _storage.data();
    }

    size_t size(void) const
    {
        return _storage.size();
    }

private:
    std::string _storage;
};