Skip to content

Commit

Permalink
修复路由匹配匹配到不是前缀的问题;修复multipart的cookies为空问题;修改cookie默认httponly为false
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfireitdiy committed Aug 21, 2019
1 parent beb9e1b commit d0f031b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions network/sf_http_base_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ inline void sf_http_base_server::raw_data_coming__(SOCKET sock,
auto req_header = request.header();

if (request.is_multipart_data()) {
sf_debug("build_boundary_context_data");
build_boundary_context_data(sock, request);
return;
}
Expand Down
7 changes: 7 additions & 0 deletions network/sf_http_part_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ inline bool sf_http_part_router::run_route(const sf_http_request &req,

if (!match_flag) {
return false;
} else {
auto new_str =
std::string(url.begin() + matched_prefix.size(), url.end());
if (!new_str.empty() && matched_prefix.back() != '/' &&
new_str[0] != '/') {
return false;
}
}

if (callback__(req, res)) {
Expand Down
1 change: 1 addition & 0 deletions network/sf_http_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ inline sf_http_request::sf_http_request(
multipart_data__ = true;
multipart_data_context__ = multipart_data;
sock__ = sock;
parse_cookies(header__, cookies__);
}

inline void sf_http_request::parse_cookies(
Expand Down
2 changes: 1 addition & 1 deletion network/sf_http_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct sf_http_cookie_t final {
std::chrono::system_clock::now(); // 生存期
std::string path = "/"; // 路径
bool secure = false; // 安全性
bool http_only = true; // http only
bool http_only = false; // http only
};

/**
Expand Down

0 comments on commit d0f031b

Please sign in to comment.