Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3b692b5

Browse files
committedApr 11, 2023
site + "/"
1 parent 34e7779 commit 3b692b5

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
 

‎server/http/GET_Handler/get_handler.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ void http_response::GET_check_state()
2222
{
2323
if (request->get_path().back() != '/')
2424
{
25-
headers["LOCATION"] = request->get_path() + '/';
25+
headers["LOCATION"] = (request->get_path() + "/");
26+
std::cout << "************" << headers["LOCATION"] <<std::endl;
2627
throw 301;
2728
}
2829
for (int i = 0;i < conf.index.size();i++)

‎server/http/http_response.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ void http_response::ERROR_handler(int x)
230230
std::cout << "Error asat :: " << x << std::endl;
231231
res_header.clear();
232232
body.clear();
233-
headers.clear();
233+
if (x != 301)
234+
headers.clear();
234235
if (file.is_open())
235236
file.close();
236237
client->events = POLLOUT;
@@ -258,7 +259,8 @@ void http_response::ERROR_handler(int x)
258259
headers["Content-Length"] = int_to_string(body.size());
259260
std::cout << "excesss = " << body << std::endl;
260261
headers["Content-Type"] = content_type["html"];
261-
if (x == 301)
262+
std::cout << "************" << headers["LOCATION"] <<std::endl;
263+
if (x == 301 && headers["LOCATION"] == "")
262264
headers["LOCATION"] = conf.return_value;
263265
res_header = "HTTP/1.1 " + int_to_string(x) + " " + errors.get_message(x) + "\n";
264266
for (std::map<std::string,std::string>::iterator it = headers.begin(); it != headers.end(); it++)

‎webserve

12.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.