Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_http_helper.hpp
1/*
2##############################################################################
3# file: ms_http_helper.hpp #
4# 'msparser' toolkit #
5# Provides functions for an HTTP link (eg to a Mascot server) #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2013 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11 * @(#)$Source: parser/inc/ms_http_helper.hpp $
12 * @(#)$Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
13 * @(#)$Date: 2018-07-30 16:23:53 +0100 $
14##############################################################################
15 */
16
17#if !defined(MS_HTTP_HELPER_HPP_)
18#define MS_HTTP_HELPER_HPP_
19
20#ifdef _WIN32
21#ifdef __MINGW__
22// No ATL or MFC support -- use curl
23#else
24#define USE_ATL
25#endif
26#endif
27
28#include <string>
29
30class LocalHelper;
31
32namespace matrix_science
33{
39 class ms_connection_settings;
40 class ms_http_helper_handles;
41 class ms_http_helper_progress;
42 class ms_http_helper_proxy_list;
43
45
55 class MS_MASCOTRESFILE_API ms_http_helper :
56 public ms_errors
57 {
58 public:
60
64 {
66 FM_text
67 };
68
69#ifdef USE_ATL
71 static void yieldToCom();
72#endif
73
75 bool getProxyConfig(std::vector<std::string> &proxyServers, std::vector<std::string> &proxyUsernames, std::vector<std::string> &proxyPasswords);
76
77#ifndef SWIG
80
82 ms_http_helper(const ms_http_helper & copy);
83
85 const ms_http_helper & operator =(const ms_http_helper & copy);
86#endif
87 void copyFrom(const ms_http_helper * right);
88
91 const std::string & baseUrl,
92 const ms_connection_settings & settings);
93
96
98 const std::string & baseUrl() const;
99
101 const ms_connection_settings & connectionSettings() const;
102#ifndef SWIG
104 ms_http_helper_return httpGetString(const std::string & action, std::string & httpGETString);
105#else // SWIG Multiple return values
106 ms_http_helper_return httpGetString(const std::string & action, std::string & OUTPUT);
107#endif
109 ms_http_helper_return httpPostFile(
110 const std::string & action,
111 const std::string & httpHeader,
112 const std::string & prologue,
113 const std::string & filename,
114 const std::string & epilogue,
115 ms_http_helper_handles & handles,
116 ms_http_helper_progress & progress);
117
119 ms_http_helper_return httpGetFile(
120 const std::string & action,
121 const std::string & filename,
122 ms_http_helper_progress & progress,
123 FileMode fileMode = FM_binary);
124
126 ms_http_helper_return httpBufferedOpen(const std::string & action);
127#ifndef SWIG
129 ms_http_helper_return httpBufferedGetString(std::string & httpBuffer, unsigned long requiredSize );
130
132 ms_http_helper_return httpGetHeader(const std::string & action, std::string & httpHeaderInfo);
133#else // SWIG Multiple return values
134 ms_http_helper_return httpBufferedGetString(std::string & OUTPUT, unsigned long requiredSize);
135 ms_http_helper_return httpGetHeader(const std::string & action, std::string & OUTPUT);
136#endif
138 ms_http_helper_return httpBufferedClose();
139
140
142 static std::string getHeaderValue(const std::string &name, const std::string & header);
143
144 private:
145
146#ifndef USE_ATL
147 bool analyseCurlResult(void * pVoidCurl, ms_http_helper_return & returnCode, std::string & performError, char * errorBuffer = NULL, std::vector< std::pair<int, std::string> > * pProxyErrors = NULL);
148 void * performCurlAndCheckHttpsCertificate(void * pVoidCurl, std::string & certificateError, std::string & systemCertPath, std::string & userCertPath, bool bCheckCertificate = true);
149#endif // USE_ATL
150
151 const std::string completeUrl(const std::string & action) const;
152
153 ms_http_helper_return httpGetLocal(
154 const std::string & action,
155 std::string & strResult,
156 const std::string & filename,
157 FileMode fileMode,
158 ms_http_helper_progress & progress);
159
160 ms_http_helper_return httpOpenLocal(const std::string & action, bool bHeaderOnly = false);
161
162 ms_http_helper_return httpGetNextLocal(
163 std::string & buffer,
164 unsigned long requiredSize );
165
166 ms_http_helper_return curlOpenLocal(const std::string & action);
167
168 ms_http_helper_return curlGetNextLocal(
169 std::string & buffer,
170 unsigned long requiredSize);
171
172 ms_http_helper_return closeLocal();
173
174 bool determineProxy();
175
176 std::string baseUrl_;
177 ms_connection_settings connectionSettings_;
178
179 // autoproxy detect cache
180 ms_http_helper_proxy_list * proxyList_;
181
182 LocalHelper * localHelper_;
183
184 };
185 // end of http_client_group
187} // namespace matrix_science
188
189#endif // MS_HTTP_HELPER_HPP_
Settings required to make an HTTP connection to a Mascot server.
Definition: ms_connection_settings.hpp:54
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
The class holds HTTP to allow a POST request to be kept alive and retrieve any output received from t...
Definition: ms_http_helper_handles.hpp:47
This holds information on the progress of a running HTTP transfer.
Definition: ms_http_helper_progress.hpp:46
Indicates any problem that may have occurred during a request to an ms_http_helper object.
Definition: ms_http_helper_return.hpp:37
The class provides HTTP, FTP and FILE protocol access to a server.
Definition: ms_http_helper.hpp:57
FileMode
Definitions for types of file content transfer.
Definition: ms_http_helper.hpp:64
@ FM_binary
Binary - the data is saved in exactly the form as it is received.
Definition: ms_http_helper.hpp:65