annotate liboctave/util/url-transfer.h @ 33634:4a70f390c85e default tip @

maint: Merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 28 May 2024 15:25:54 +0200
parents 4b601ca024d5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31837
diff changeset
3 // Copyright (C) 2006-2024 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_url_transfer_h)
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #define octave_url_transfer_h 1
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21017
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21017
diff changeset
30
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25147
diff changeset
31 #include <istream>
24254
4bca68f0d8d5 use shared_ptr to manage url_transfer object
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
32 #include <memory>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25147
diff changeset
33 #include <ostream>
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <string>
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
30429
e38202d3628d provide header file for forward declaration of Array<T> template
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
36 #include "Array-fwd.h"
23442
53f5f8231c37 allow most header files to be compiled separately
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
37 #include "str-vec.h"
53f5f8231c37 allow most header files to be compiled separately
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
38
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30826
diff changeset
39 OCTAVE_BEGIN_NAMESPACE(octave)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30826
diff changeset
40
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
41 struct weboptions
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
42 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
43 std::string UserAgent;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
44 long Timeout;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
45 std::string Username;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
46 std::string Password;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
47 Array<std::string> HeaderFields;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
48 std::string ContentReader;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
49 std::string RequestMethod;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
50 std::string ArrayFormat;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
51 std::string CertificateFilename;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
52 };
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
53
32628
ae4e19c0a2b1 maint: Place class name and class keyword on one line.
Rik <rik@octave.org>
parents: 31837
diff changeset
54 class OCTAVE_API base_url_transfer
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
55 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
56 public:
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
57
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
58 friend class url_transfer;
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
59
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
60 base_url_transfer ();
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
62 base_url_transfer (const std::string& host,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
63 const std::string& /* user_arg */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
64 const std::string& /* passwd */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
65 std::ostream& os);
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
67 base_url_transfer (const std::string& url, std::ostream& os);
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
31837
febd82d1a8de use new macros to consistently delete copy and move member functions
John W. Eaton <jwe@octave.org>
parents: 31771
diff changeset
69 OCTAVE_DISABLE_COPY_MOVE (base_url_transfer)
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
70
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
71 virtual ~base_url_transfer () = default;
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
73 bool is_valid () const { return m_valid; }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
75 bool good () const { return m_valid && m_ok; }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
77 virtual void perform () { }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
78
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
79 virtual std::string lasterror () const { return m_errmsg; }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
81 virtual std::ostream& set_ostream (std::ostream& /* os */)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
82 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
83 return *m_curr_ostream;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
84 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
86 virtual std::istream& set_istream (std::istream& /* is */)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
87 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
88 return *m_curr_istream;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
89 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
91 virtual void ascii () { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
93 virtual void binary () { }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
94
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
95 bool is_ascii () const { return m_ascii_mode; }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
97 bool is_binary () const { return ! m_ascii_mode; }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
99 virtual void cwd (const std::string& /* path */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
101 virtual void del (const std::string& /* file */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
103 virtual void rmdir (const std::string& /* path */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
105 virtual void mkdir (const std::string& /* path */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
107 virtual void rename (const std::string& /* oldname */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
108 const std::string& /* newname */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
110 virtual void put (const std::string& /* file */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
111 std::istream& /* is */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
113 virtual void get (const std::string& /* file */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
114 std::ostream& /* os */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
116 void mget_directory (const std::string& directory,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
117 const std::string& target);
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
119 string_vector mput_directory (const std::string& base,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
120 const std::string& directory);
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
121
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
122 virtual void dir () { }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
123
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
124 virtual string_vector list () { return string_vector (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
126 virtual void get_fileinfo (const std::string& /* filename */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
127 double& /* filesize */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
128 OCTAVE_TIME_T& /* filetime */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
129 bool& /* fileisdir */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
131 virtual std::string pwd () { return ""; }
17596
43b9181340fb separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17557
diff changeset
132
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
133 virtual void http_get (const Array<std::string>& /* param */) { }
17596
43b9181340fb separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17557
diff changeset
134
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
135 virtual void http_post (const Array<std::string>& /* param */) { }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
137 virtual void http_action (const Array<std::string>& /* param */,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
138 const std::string& /* action */) { }
17596
43b9181340fb separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17557
diff changeset
139
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
140 virtual void cookie_jar (const std::string& /* filename */) { }
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
141
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
142 virtual void set_header_fields (const Array<std::string>& /* param */) { }
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
143
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
144 virtual void form_data_post (const Array<std::string>& /* param */) { }
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
145
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
146 virtual void set_weboptions (const struct weboptions& /* param */) { }
27174
b42350f18afb style fixes for url-transfer classes
John W. Eaton <jwe@octave.org>
parents: 27048
diff changeset
147
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
148 protected:
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
149
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
150 // Host for ftp transfers or full URL for http requests.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
151 std::string m_host_or_url;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
152 bool m_valid;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
153 bool m_ftp;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
154 bool m_ascii_mode;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
155 bool m_ok;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
156 std::string m_errmsg;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
157 std::istream *m_curr_istream;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
158 std::ostream *m_curr_ostream;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
159 };
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
32628
ae4e19c0a2b1 maint: Place class name and class keyword on one line.
Rik <rik@octave.org>
parents: 31837
diff changeset
161 class OCTAVE_API url_transfer
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
162 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
163 public:
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
165 url_transfer ();
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
167 url_transfer (const std::string& host, const std::string& user,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
168 const std::string& passwd, std::ostream& os);
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
169
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
170 url_transfer (const std::string& url, std::ostream& os);
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
172 url_transfer (const url_transfer&) = default;
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
173
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
174 url_transfer& operator = (const url_transfer&) = default;
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
175
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
176 ~url_transfer () = default;
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
177
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
178 bool is_valid () const { return m_rep->is_valid (); }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
179
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
180 bool good () const { return m_rep->good (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
182 std::string lasterror () const { return m_rep->lasterror (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
183
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
184 std::ostream& set_ostream (std::ostream& os)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
185 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
186 return m_rep->set_ostream (os);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
187 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
189 std::istream& set_istream (std::istream& is)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
190 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
191 return m_rep->set_istream (is);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
192 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
194 void ascii () { m_rep->ascii (); }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
195
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
196 void binary () { m_rep->binary (); }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
197
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
198 bool is_ascii () const { return m_rep->is_ascii (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
200 bool is_binary () const { return m_rep->is_binary (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
202 void cwd (const std::string& path) { m_rep->cwd (path); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
204 void del (const std::string& file) { m_rep->del (file); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
206 void rmdir (const std::string& path) { m_rep->rmdir (path); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
208 void mkdir (const std::string& path) { m_rep->mkdir (path); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
210 void rename (const std::string& oldname, const std::string& newname)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
211 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
212 m_rep->rename (oldname, newname);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
213 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
215 void put (const std::string& file, std::istream& is)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
216 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
217 m_rep->put (file, is);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
218 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
220 void get (const std::string& file, std::ostream& os)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
221 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
222 m_rep->get (file, os);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
223 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
225 void mget_directory (const std::string& directory,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
226 const std::string& target)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
227 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
228 m_rep->mget_directory (directory, target);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
229 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
231 string_vector mput_directory (const std::string& base,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
232 const std::string& directory)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
233 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
234 return m_rep->mput_directory (base, directory);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
235 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
237 void dir () { m_rep->dir (); }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
238
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
239 string_vector list () { return m_rep->list (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
241 void get_fileinfo (const std::string& filename, double& filesize,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
242 OCTAVE_TIME_T& filetime, bool& fileisdir)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
243 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
244 m_rep->get_fileinfo (filename, filesize, filetime, fileisdir);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
245 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
246
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
247 std::string pwd () { return m_rep->pwd (); }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
248
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
249 void http_get (const Array<std::string>& param)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
250 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
251 m_rep->http_get (param);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
252 }
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
253
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
254 void http_post (const Array<std::string>& param)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
255 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
256 m_rep->http_post (param);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
257 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
258
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
259 void http_action (const Array<std::string>& param,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
260 const std::string& action)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
261 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
262 m_rep->http_action (param, action);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
263 }
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
264
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
265 void cookie_jar (const std::string& filename)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
266 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
267 m_rep->cookie_jar (filename);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
268 }
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
269
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
270 void set_header_fields (const Array<std::string>& param)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
271 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
272 m_rep->set_header_fields (param);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
273 }
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
274
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
275 void form_data_post (const Array<std::string>& param)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
276 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
277 m_rep->form_data_post (param);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
278 }
27048
159402e52cfa New implementation of RESTful web services as part of GSoC 2018 (patch #9795).
Sahil Yadav <yadavsahil5198@gmail.com>
parents: 26376
diff changeset
279
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
280 void set_weboptions (const struct weboptions& param)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
281 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
282 m_rep->set_weboptions (param);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
283 }
27174
b42350f18afb style fixes for url-transfer classes
John W. Eaton <jwe@octave.org>
parents: 27048
diff changeset
284
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
285 private:
17596
43b9181340fb separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17557
diff changeset
286
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
287 std::shared_ptr<base_url_transfer> m_rep;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
288 };
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30826
diff changeset
289
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30826
diff changeset
290 OCTAVE_END_NAMESPACE(octave)
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
291
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292 #endif