KiCad PCB EDA Suite
kicad_curl_easy.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Mark Roszko <mark.roszko@gmail.com>
5  * Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 #ifndef KICAD_CURL_EASY_H_
25 #define KICAD_CURL_EASY_H_
26 
27 /*
28  * KICAD_CURL_EASY.h must included before wxWidgets because on Windows,
29  * kicad_curl.h does not include curl.h, because wxWidgets ends up including windows.h
30  * before winsocks2.h inside curl and curl.h causes build warnings if included before and wxxxx.h
31  *
32  * so including kicad_curl.h could be needed in a few sources
33  */
34 
35 #include <string>
36 
37 typedef void CURL;
38 struct curl_slist;
39 
60 {
61 public:
64 
72  void Perform();
73 
81  void SetHeader( const std::string& aName, const std::string& aValue );
82 
90  bool SetUserAgent( const std::string& aAgent );
91 
99  bool SetURL( const std::string& aURL );
100 
109  bool SetFollowRedirects( bool aFollow );
110 
118  const std::string GetErrorText( int aCode );
119 
124  const std::string& GetBuffer()
125  {
126  return m_buffer;
127  }
128 
129 private:
138  template <typename T> int setOption( int aOption, T aArg );
139 
140 
142  curl_slist* m_headers;
143  std::string m_buffer;
144 };
145 
146 #endif // KICAD_CURL_EASY_H_
bool SetUserAgent(const std::string &aAgent)
Function SetUserAgent sets the request user agent.
void Perform()
Function perform equivalent to curl_easy_perform.
bool SetFollowRedirects(bool aFollow)
Function SetFollowRedirects enables the following of HTTP(s) and other redirects, by default curl doe...
T
enum T contains all this lexer's tokens.
Class KICAD_CURL_EASY wrapper interface around the curl_easy API.
int setOption(int aOption, T aArg)
Function setOption sets a curl option, only supports single parameter curl options.
void CURL
const std::string & GetBuffer()
Function GetBuffer returns a const reference to the recevied data buffer.
curl_slist * m_headers
const std::string GetErrorText(int aCode)
Function GetErrorText fetches CURL's "friendly" error string for a given error code.
bool SetURL(const std::string &aURL)
Function SetURL sets the request URL.
std::string m_buffer
void SetHeader(const std::string &aName, const std::string &aValue)
Function SetHeader sets an arbitrary header for the HTTP(s) request.