blob: d7bf73f3febd07b1cabe857eac16f1c2bcf99413 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* Copyright (C) 2015-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "interfaces/legacy/AddonClass.h"
#include <vector>
struct HTTPPythonRequest;
namespace XBMCAddon
{
namespace xbmcwsgi
{
// Iterator for the wsgi.input stream.
class WsgiInputStreamIterator : public AddonClass
{
public:
WsgiInputStreamIterator();
~WsgiInputStreamIterator() override;
#ifdef DOXYGEN_SHOULD_USE_THIS
/// \ingroup python_xbmcwsgi_WsgiInputStream
/// \python_func{ read([size]) }
///
/// Read a maximum of `<size>` bytes from the wsgi.input stream.
///
/// @param size [opt] bytes to read
/// @return Returns the readed string
///
read(...);
#else
String read(unsigned long size = 0) const;
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
/// \ingroup python_xbmcwsgi_WsgiInputStream
/// \python_func{ readline([size]) }
///
/// Read a full line up to a maximum of `<size>` bytes from the wsgi.input
/// stream.
///
/// @param size [opt] bytes to read
/// @return Returns the readed string line
///
read(...);
#else
String readline(unsigned long size = 0) const;
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
/// \ingroup python_xbmcwsgi_WsgiInputStream
/// \python_func{ readlines([sizehint]) }
///
/// Read multiple full lines up to at least `<sizehint>` bytes from the
/// wsgi.input stream and return them as a list.
///
/// @param sizehint [opt] bytes to read
/// @return Returns a list readed string lines
///
read(...);
#else
std::vector<String> readlines(unsigned long sizehint = 0) const;
#endif
#if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
WsgiInputStreamIterator(const String& data, bool end = false);
WsgiInputStreamIterator& operator++();
bool operator==(const WsgiInputStreamIterator& rhs);
bool operator!=(const WsgiInputStreamIterator& rhs);
String& operator*();
inline bool end() const { return m_remaining <= 0; }
protected:
String m_data;
mutable unsigned long m_offset = 0;
mutable unsigned long m_remaining = 0;
private:
String m_line;
#endif
};
/// \defgroup python_xbmcwsgi_WsgiInputStream WsgiInputStream
/// \ingroup python_xbmcwsgi
/// @{
/// @brief **Represents the wsgi.input stream to access data from a HTTP request.**
///
/// \python_class{ WsgiInputStream() }
///
///-------------------------------------------------------------------------
///
class WsgiInputStream : public WsgiInputStreamIterator
{
public:
WsgiInputStream();
~WsgiInputStream() override;
#if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
WsgiInputStreamIterator* begin();
WsgiInputStreamIterator* end();
/**
* Sets the given request.
*/
void SetRequest(HTTPPythonRequest* request);
HTTPPythonRequest* m_request;
#endif
};
}
}
|