Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/request #5

Merged
7 commits merged into from
Jul 14, 2024
Merged

Feat/request #5

7 commits merged into from
Jul 14, 2024

Conversation

miooo0o
Copy link
Collaborator

@miooo0o miooo0o commented Jul 12, 2024

A simple request/response implementation that can be used for testing.
GET: parse the request and send the appropriate response via handleRequest.

But not sure what,

  • The response to the correct header/body needs more testing.
  • Only .html has been tested, not sure about mime-type yet.

and extra: I added the debug conf-available in vscode as a sample.
You can use it loosely and feel free to modify it.

miooo0o added 6 commits July 11, 2024 20:46
update: doc,
todo: Check for sustainable connectivity, especially fromFile, which is only tested on .html files yet.
@miooo0o miooo0o requested a review from san-ghun July 12, 2024 19:41
@miooo0o miooo0o self-assigned this Jul 12, 2024
Copy link
Owner

@san-ghun san-ghun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for your work!
Please check my review and consider my opinions.
If you have any other opinions or counter offer, please leave comment or tell me.

# include "HttpRequest.hpp"
# include "HttpResponse.hpp"

# define FOLDER_PATH "./www/static"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just would like to let you know that the default directory should and will be set by the Config file in future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks for letting me know. Please remind me to handle this linking part later when you give the relevant PR.

}

std::string getDefualtPagePath(int page_code)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The "default page" is an .html file that is default for certain directory, the filename something like "index.html", but the method is currently dealing with error page, instead.
    • I think the name of the method would better with "getErrorPage".
  • Typo, getDefualtPagePath() -> getDefaultPagePath()

Copy link
Collaborator Author

@miooo0o miooo0o Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now that I think about it again, Let's just go to getErrorPage

return ("application/octet-stream");
}

bool StaticFileHandler::fileExists(const std::string path) const
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 얘는 어디에 쓰시려고 만드신 거 일까요? 사용처를 못 찾아서 ;;;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staticFileHandler.cpp
line 32 if (!fileExists(filePath))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether to continue using the method or not, so I didn't write a separate doc for: the name specifies the function feature. sorry!

/// @return HttpResponse The created HttpResponse object.
HttpResponse HttpResponse::fromFile(const std::string filePath)
HttpResponse HttpResponse::fromFile(const std::string file_path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Suggestion: How about making another constructor for HttpResponse class that take an input parameter of file_path to initiate, instead of using a method to make and return an instance of it.
HttpResponse::HttpResponse(const std::string file_path)
	: _statusCode(200), _statusMessage("OK")
{
	fromFile(file_path);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'll update to reflect that.

@san-ghun
Copy link
Owner

Also thanks for your debug configuration with vscode.
But I am afraid that you run your vscode on Linux machine, and I run my vscode in Mac. So, I guess there be some huddles I have to overcome. However I will try my best to utilise it.

Copy link
Collaborator Author

@miooo0o miooo0o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment

return ("application/octet-stream");
}

bool StaticFileHandler::fileExists(const std::string path) const
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staticFileHandler.cpp
line 32 if (!fileExists(filePath))

/// @return HttpResponse The created HttpResponse object.
HttpResponse HttpResponse::fromFile(const std::string filePath)
HttpResponse HttpResponse::fromFile(const std::string file_path)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'll update to reflect that.

}

std::string getDefualtPagePath(int page_code)
Copy link
Collaborator Author

@miooo0o miooo0o Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now that I think about it again, Let's just go to getErrorPage

# include "HttpRequest.hpp"
# include "HttpResponse.hpp"

# define FOLDER_PATH "./www/static"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks for letting me know. Please remind me to handle this linking part later when you give the relevant PR.

return ("application/octet-stream");
}

bool StaticFileHandler::fileExists(const std::string path) const
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether to continue using the method or not, so I didn't write a separate doc for: the name specifies the function feature. sorry!

@miooo0o miooo0o closed this pull request by merging all changes into san-ghun:main in 4b71224 Jul 14, 2024
@san-ghun
Copy link
Owner

Closing #5 by merging current PR into #6

@miooo0o miooo0o deleted the feat/request branch August 8, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants