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

[톰캣 구현하기 - 1, 2단계] 테오(최우성) 미션 제출합니다. #304

Merged
merged 48 commits into from
Sep 5, 2023

Conversation

woosung1223
Copy link
Member

@woosung1223 woosung1223 commented Sep 2, 2023

안녕하세요 토리! 반갑습니다~

1, 2단계 구현 마치고 리뷰 요청드립니다!

아래는 큰 흐름을 도식화한 그림인데, 리뷰하실 때 참고하시면 좋을 것 같아요 🙇‍♂️

image

@woosung1223 woosung1223 self-assigned this Sep 2, 2023
Copy link
Member

@ezzanzzan ezzanzzan left a comment

Choose a reason for hiding this comment

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

안녕하세요 테오 ! 토리입니다 🙇‍♀️

전체적으로 코드 구조가 깔끔하고 도식화한 그림까지 주셔서 리뷰 하는데 큰 어려움이 없었습니다 !
코드가 술술 읽혀서 재밌었어요 👍

리뷰 남긴 부분 확인 후 다시 요청 부탁드려요 !
좋은 하루 되세요 🌈🙇‍♀️

Comment on lines 40 to 45
if (reader.ready()) {
char[] buffer = new char[1024];
reader.read(buffer);
body.addAll(Arrays.asList(new String(buffer).trim()
.split("&")));
}
Copy link
Member

Choose a reason for hiding this comment

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

body로 들어오는 값이 길어진다면 잘릴 위험이 있을 것 같아요 !
또한 body값으로 &가 delimiter가 아닌 값이 들어올 수도 있지 않을까요 !?

Copy link
Member Author

Choose a reason for hiding this comment

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

말씀해주셔서 Request Body에 어떤 값들이 들어올 수 있는지 조사를 조금 해보았는데요!

현재는 HTML 파일의 form 태그를 통해 로그인 정보를 보내는 방식이다보니
기본으로 Content-Type을 application/x-www-form-urlencoded 로 사용합니다.

이 경우 데이터가 key=value&key=value 형식으로 들어오게 되고, 그렇기 때문에 위의 코드가 정상적으로 작동하는 것 같습니다.

토리가 말씀주신대로 Content-Type에 따라 여러 Delimiter가 들어올 수 있더라구요.
Postman으로 form-data를 작성해 요청해보기도 했는데, 이 경우에는 multipart/form-data를 사용하고 delimiter를 클라이언트가 정의하기 때문에 파싱 자체가 불가능했었습니다 🥲

현재는 다양한 Content-Type을 수용할 필요는 없으나 추가적으로 JSON 정도까지만 파싱이 가능하게 구현해보려고 하는데, 어떻게 생각하시는지 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

body buffer 크기 부분은 Content-Length 를 사용하는 쪽으로 수정해보도록 하겠습니다!

Copy link
Member

Choose a reason for hiding this comment

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

얘기나눴던 부분인데 다시 정리해서 리뷰 남기자면 !
제가 의도한 방향은 "&"로 파싱하는 부분을 한 단계 밖이나, 실제로 body값에 대한 파싱이 필요한 부분에서 실행하는게 어떨까 였습니다 !
외부에서 하면 조금 더 content-type에 따라 분기를 나눠서 실행하기도 편하고 로직이 추가되기도 편할 것 같았습니다 ㅎㅎ

말씀해주신대로 현재는 다양한 Content-Type을 수용할 필요가 없으니 따로 파싱을 추가하지 않아도 괜찮을 것 같아요 👍

@@ -48,11 +48,11 @@ class OutputStream_학습_테스트 {
void OutputStream은_데이터를_바이트로_처리한다() throws IOException {
final byte[] bytes = {110, 101, 120, 116, 115, 116, 101, 112};
Copy link
Member

Choose a reason for hiding this comment

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

해당 학습 테스트는 고쳐지지 않은 것 같은데 시간 될 때 해보시면 좋을 거 같아요 ˙ᵕ˙ 👍🐤

@sonarcloud
Copy link

sonarcloud bot commented Sep 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.20.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

Copy link
Member

@ezzanzzan ezzanzzan left a comment

Choose a reason for hiding this comment

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

안녕하세요 테오 ! 토리입니다 ˙ᵕ˙
리뷰 빠르게 반영해주셨네요 👍
원래도 깔끔한 코드였는데 더 빛이 나고 있네요 ..

이번 단계는 머지 하도록 하겠습니다 !!
자그만 리뷰 몇 개 남겼는데 다음 단계 진행하면서 같이 생각해보시면 좋을 것 같아요 ~
다음 단계에서 봬요 👋

private static RequestBody extractBody(BufferedReader reader, int contentLength) throws IOException {
List<String> body = new ArrayList<>();
if (reader.ready()) {
char[] buffer = new char[contentLength];
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines 40 to 45
if (reader.ready()) {
char[] buffer = new char[1024];
reader.read(buffer);
body.addAll(Arrays.asList(new String(buffer).trim()
.split("&")));
}
Copy link
Member

Choose a reason for hiding this comment

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

얘기나눴던 부분인데 다시 정리해서 리뷰 남기자면 !
제가 의도한 방향은 "&"로 파싱하는 부분을 한 단계 밖이나, 실제로 body값에 대한 파싱이 필요한 부분에서 실행하는게 어떨까 였습니다 !
외부에서 하면 조금 더 content-type에 따라 분기를 나눠서 실행하기도 편하고 로직이 추가되기도 편할 것 같았습니다 ㅎㅎ

말씀해주신대로 현재는 다양한 Content-Type을 수용할 필요가 없으니 따로 파싱을 추가하지 않아도 괜찮을 것 같아요 👍

Comment on lines 13 to 17
public static Headers fromMap(Map<String, String> mappings) {
return new Headers(mappings);
}

public static Headers fromLines(List<String> lines) {
Copy link
Member

Choose a reason for hiding this comment

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

네이밍 좋은데요 ? 👍

CONTENT_TYPE("Content-Type"),
CONTENT_LENGTH("Content-Length"),
SET_COOKIE("Set-Cookie"),
LOCATION("Location");
Copy link
Member

@ezzanzzan ezzanzzan Sep 5, 2023

Choose a reason for hiding this comment

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

👍


verify(outputStream, atLeastOnce()).close();
verify(outputStream, atLeastOnce()).close();
}
Copy link
Member

Choose a reason for hiding this comment

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

try 안의 outputStream을 밖에서 선언해준 뒤 변수를 사용하면 확실하게 검증이 될 거 같네요 !!

@ezzanzzan ezzanzzan merged commit e310234 into woowacourse:woosung1223 Sep 5, 2023
2 checks passed
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