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