OpenMS
Loading...
Searching...
No Matches
NetworkGetRequest.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
12
13#include <string>
14#include <vector>
15
16namespace OpenMS
17{
36 class OPENMS_DLLAPI NetworkGetRequest
37 {
38 public:
41
49 void setUrl(const std::string& url);
50
58 void setTimeout(int seconds);
59
79 void run();
80
86 std::string getResponse() const;
87
93 const std::vector<char>& getResponseBinary() const;
94
101 bool hasError() const;
102
108 std::string getErrorString() const;
109
110 private:
113
114 std::vector<char> response_bytes_;
115 std::string url_;
116 int timeout_ = 0;
117 bool has_error_ = false;
118 std::string error_string_;
119 };
120}
Synchronous HTTP GET request backed by libcurl.
Definition NetworkGetRequest.h:37
NetworkGetRequest(const NetworkGetRequest &)=delete
const std::vector< char > & getResponseBinary() const
Raw response body.
void run()
Execute the GET request synchronously.
std::string url_
Definition NetworkGetRequest.h:115
void setTimeout(int seconds)
Set the request timeout in seconds.
std::string error_string_
Definition NetworkGetRequest.h:118
std::string getResponse() const
Response body as a string.
std::vector< char > response_bytes_
Definition NetworkGetRequest.h:114
bool hasError() const
Whether the last run produced an error.
void setUrl(const std::string &url)
Set the URL to request.
std::string getErrorString() const
Human-readable description of the last error.
NetworkGetRequest & operator=(const NetworkGetRequest &)=delete
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19