fixed some warning
This commit is contained in:
@@ -9,7 +9,7 @@ int main() {
|
||||
chttp::Server s { };
|
||||
chttp::Router router { };
|
||||
router.Get("/about", [](chttp::Request req, chttp::Response res) {
|
||||
cout << req.URL().GetParam("key") << endl;
|
||||
cout << req.URL().GetURLParam("key") << endl;
|
||||
res.ServeHtml("index.html");
|
||||
});
|
||||
s.SetRouter(router);
|
||||
|
||||
+7
-5
@@ -102,13 +102,15 @@ void Response::NotFound() {
|
||||
|
||||
void Response::WriteSocket(Sock_type sock, const char* buffer, size_t size,
|
||||
int flags) {
|
||||
int length = size;
|
||||
int length = static_cast<int>(size);
|
||||
if (size == 0)
|
||||
length = strlen(buffer);
|
||||
length = static_cast<int>(strlen(buffer));
|
||||
send(sock, buffer, length, flags);
|
||||
//std::cout << "write to socket:";
|
||||
//for (size_t i = 0; i < length; ++i)
|
||||
// cout << buffer[i];
|
||||
#ifdef DEBUG
|
||||
std::cout << "write to socket:";
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
cout << buffer[i];
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
inline void Response::CloseSocket(Sock_type sock)
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public:
|
||||
}
|
||||
|
||||
inline void SetContentType(std::string&& content_type) {
|
||||
header.Content()["Content-Type"] = content_type;
|
||||
header.Content()["content-type"] = content_type;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ int Server::GetLine(Sock_type sock, char* buf, int size) {
|
||||
|
||||
vector<string> Server::ReadRequest(const Sock_type& clnt_sock) {
|
||||
int char_count { 1 };
|
||||
char buffer[buffer_size];
|
||||
char buffer[buffer_size] = "";
|
||||
vector<string> content { };
|
||||
while (char_count > 0 && strcmp("\n", buffer)) {
|
||||
char_count = GetLine(clnt_sock, buffer, sizeof(buffer));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "url.h"
|
||||
using namespace std;
|
||||
std::string chttp::URL::GetParam(const std::string& key)const
|
||||
std::string chttp::URL::GetURLParam(const std::string& key)const
|
||||
{
|
||||
smatch result;
|
||||
if (regex_search(_url.cbegin(), _url.cend(), result, regex{ key + "=(.*?)&" })
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
inline std::string GetURL() const { return _url; }
|
||||
inline std::string& GetURL() { return _url; }
|
||||
|
||||
std::string GetParam(const std::string& key)const;
|
||||
std::string GetURLParam(const std::string& key)const;
|
||||
|
||||
inline bool operator == (const URL& other)const { return this->_url == other._url; }
|
||||
inline bool operator != (const URL& other)const { return this->_url != other._url; }
|
||||
|
||||
Reference in New Issue
Block a user