Rename BasicRestClient to RestBasicClient.
This commit is contained in:
@@ -9,7 +9,6 @@ endif()
|
|||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
version.h
|
|
||||||
globals.h
|
globals.h
|
||||||
http_async_client.h
|
http_async_client.h
|
||||||
http_client.h
|
http_client.h
|
||||||
@@ -24,8 +23,8 @@ set(HEADERS
|
|||||||
http_server.h
|
http_server.h
|
||||||
logger.h
|
logger.h
|
||||||
queue.h
|
queue.h
|
||||||
basic_rest_client.h
|
|
||||||
rest_async_client.h
|
rest_async_client.h
|
||||||
|
rest_basic_client.h
|
||||||
rest_client.h
|
rest_client.h
|
||||||
rest_request_handler.h
|
rest_request_handler.h
|
||||||
rest_server.h
|
rest_server.h
|
||||||
@@ -33,6 +32,7 @@ set(HEADERS
|
|||||||
rest_service_manager.h
|
rest_service_manager.h
|
||||||
url.h
|
url.h
|
||||||
utility.h
|
utility.h
|
||||||
|
version.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef WEBCC_BASIC_REST_CLIENT_H_
|
#ifndef WEBCC_REST_BASIC_CLIENT_H_
|
||||||
#define WEBCC_BASIC_REST_CLIENT_H_
|
#define WEBCC_REST_BASIC_CLIENT_H_
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -12,11 +12,11 @@
|
|||||||
namespace webcc {
|
namespace webcc {
|
||||||
|
|
||||||
template <class HttpClientType>
|
template <class HttpClientType>
|
||||||
class BasicRestClient {
|
class RestBasicClient {
|
||||||
public:
|
public:
|
||||||
// If |port| is empty, |host| will be checked to see if it contains port or
|
// If |port| is empty, |host| will be checked to see if it contains port or
|
||||||
// not (separated by ':').
|
// not (separated by ':').
|
||||||
explicit BasicRestClient(const std::string& host,
|
explicit RestBasicClient(const std::string& host,
|
||||||
const std::string& port = "")
|
const std::string& port = "")
|
||||||
: host_(host), port_(port) {
|
: host_(host), port_(port) {
|
||||||
if (port_.empty()) {
|
if (port_.empty()) {
|
||||||
@@ -28,9 +28,9 @@ class BasicRestClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~BasicRestClient() = default;
|
~RestBasicClient() = default;
|
||||||
|
|
||||||
WEBCC_DELETE_COPY_ASSIGN(BasicRestClient);
|
WEBCC_DELETE_COPY_ASSIGN(RestBasicClient);
|
||||||
|
|
||||||
void SetTimeout(int seconds) {
|
void SetTimeout(int seconds) {
|
||||||
http_client_.SetTimeout(seconds);
|
http_client_.SetTimeout(seconds);
|
||||||
@@ -120,4 +120,4 @@ class BasicRestClient {
|
|||||||
|
|
||||||
} // namespace webcc
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // WEBCC_BASIC_REST_CLIENT_H_
|
#endif // WEBCC_REST_BASIC_CLIENT_H_
|
||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
#ifndef WEBCC_REST_CLIENT_H_
|
#ifndef WEBCC_REST_CLIENT_H_
|
||||||
#define WEBCC_REST_CLIENT_H_
|
#define WEBCC_REST_CLIENT_H_
|
||||||
|
|
||||||
#include "webcc/basic_rest_client.h"
|
#include "webcc/rest_basic_client.h"
|
||||||
#include "webcc/http_client.h"
|
#include "webcc/http_client.h"
|
||||||
|
|
||||||
namespace webcc {
|
namespace webcc {
|
||||||
|
|
||||||
typedef BasicRestClient<HttpClient> RestClient;
|
typedef RestBasicClient<HttpClient> RestClient;
|
||||||
|
|
||||||
} // namespace webcc
|
} // namespace webcc
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ void RestRequestHandler::HandleSession(HttpSessionPtr session) {
|
|||||||
|
|
||||||
Url url(http_request.url(), /*decode*/true);
|
Url url(http_request.url(), /*decode*/true);
|
||||||
|
|
||||||
if (!url.IsValid()) {
|
if (!url.IsPathValid()) {
|
||||||
session->SendResponse(HttpStatus::kBadRequest);
|
session->SendResponse(HttpStatus::kBadRequest);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#ifndef WEBCC_REST_SSL_CLIENT_H_
|
#ifndef WEBCC_REST_SSL_CLIENT_H_
|
||||||
#define WEBCC_REST_SSL_CLIENT_H_
|
#define WEBCC_REST_SSL_CLIENT_H_
|
||||||
|
|
||||||
#include "webcc/basic_rest_client.h"
|
#include "webcc/rest_basic_client.h"
|
||||||
#include "webcc/http_ssl_client.h"
|
#include "webcc/http_ssl_client.h"
|
||||||
|
|
||||||
namespace webcc {
|
namespace webcc {
|
||||||
|
|
||||||
typedef BasicRestClient<HttpSslClient> RestSslClient;
|
typedef RestBasicClient<HttpSslClient> RestSslClient;
|
||||||
|
|
||||||
} // namespace webcc
|
} // namespace webcc
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -258,8 +258,12 @@ Url::Url(const std::string& str, bool decode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Url::IsValid() const {
|
bool Url::IsPathValid() const {
|
||||||
return !path_.empty();
|
// URL path must be absolute.
|
||||||
|
if (path_.empty() || path_[0] != '/') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Url::SplitPath(const std::string& path) {
|
std::vector<std::string> Url::SplitPath(const std::string& path) {
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ class Url {
|
|||||||
Url() = default;
|
Url() = default;
|
||||||
Url(const std::string& str, bool decode);
|
Url(const std::string& str, bool decode);
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsPathValid() const;
|
||||||
|
|
||||||
const std::string& path() const {
|
const std::string& path() const {
|
||||||
return path_;
|
return path_;
|
||||||
|
|||||||
Reference in New Issue
Block a user