@@ -115,24 +115,9 @@ namespace lklibs {
115115 *
116116 * @param method: HTTP method to be used for the request
117117 */
118- HttpRequest &setMethod (const HttpMethod &method) {
119-
120- this ->method = [method] {
121- switch (method) {
122- case HttpMethod::GET:
123- return " GET" ;
124- case HttpMethod::POST:
125- return " POST" ;
126- case HttpMethod::PUT:
127- return " PUT" ;
128- case HttpMethod::DELETE_:
129- return " DELETE" ;
130- case HttpMethod::PATCH:
131- return " PATCH" ;
132- default :
133- return " GET" ;
134- }
135- }();
118+ HttpRequest &setMethod (const HttpMethod &method) noexcept {
119+
120+ this ->method = HttpMethodStrings[static_cast <int >(method)];
136121
137122 return *this ;
138123 }
@@ -142,7 +127,7 @@ namespace lklibs {
142127 *
143128 * @param queryString: Query string to be sent with the request
144129 */
145- HttpRequest &setQueryString (const std::string &queryString) {
130+ HttpRequest &setQueryString (const std::string &queryString) noexcept {
146131
147132 if (this ->url .find (' ?' ) != std::string::npos) {
148133
@@ -163,7 +148,7 @@ namespace lklibs {
163148 *
164149 * @param payload: Payload to be sent with the request
165150 */
166- HttpRequest &setPayload (const std::string &payload) {
151+ HttpRequest &setPayload (const std::string &payload) noexcept {
167152
168153 this ->payload = payload;
169154
@@ -173,7 +158,7 @@ namespace lklibs {
173158 /* *
174159 * @brief Set the return format for the request as binary
175160 */
176- HttpRequest &returnAsBinary () {
161+ HttpRequest &returnAsBinary () noexcept {
177162
178163 this ->returnFormat = ReturnFormat::BINARY;
179164
@@ -183,7 +168,7 @@ namespace lklibs {
183168 /* *
184169 * @brief Ignore SSL errors when making HTTP requests
185170 */
186- HttpRequest &ignoreSslErrors () {
171+ HttpRequest &ignoreSslErrors () noexcept {
187172
188173 this ->sslErrorsWillBeIgnored = true ;
189174
@@ -196,7 +181,7 @@ namespace lklibs {
196181 * @param key: Header key
197182 * @param value: Header value
198183 */
199- HttpRequest &addHeader (const std::string &key, const std::string &value) {
184+ HttpRequest &addHeader (const std::string &key, const std::string &value) noexcept {
200185
201186 this ->headers [key] = value;
202187
@@ -223,6 +208,14 @@ namespace lklibs {
223208 BINARY
224209 };
225210
211+ const char * HttpMethodStrings[5 ] = {
212+ " GET" ,
213+ " POST" ,
214+ " PUT" ,
215+ " DELETE" ,
216+ " PATCH"
217+ };
218+
226219 std::string url;
227220 std::string method = " GET" ;
228221 std::string payload;
0 commit comments