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

[🐱 Tomcat κ΅¬ν˜„ν•˜κΈ° 1단계] 제우슀(μ‹ μž¬μš°) λ―Έμ…˜ μ œμΆœν•©λ‹ˆλ‹€. #552

Merged
merged 11 commits into from
Sep 9, 2024

Conversation

zeus6768
Copy link
Member

@zeus6768 zeus6768 commented Sep 6, 2024

μ•ˆλ…•ν•˜μ„Έμš” μ•ˆλ‚˜ πŸ‘‹

ν”„λ‘œμ νŠΈμ™€ λ―Έμ…˜μ„ λ³‘ν–‰ν•˜λŠ” 게 쉽지 μ•Šλ„€μš” 😭

μ—­ν• λ³„λ‘œ 클래슀λ₯Ό λΆ„λ¦¬ν•˜λ €λ‹€ μ‹œκ°„μ΄ λΆ€μ‘±ν•΄ Http11Processor에 λŒ€λΆ€λΆ„μ˜ λ‘œμ§μ„ λ•Œλ €λ„£μ€ μƒν™©μ΄μ—μš”.

그런데 μ•Œκ³ λ³΄λ‹ˆ 3단계에 λ¦¬νŒ©ν† λ§μ΄ μ˜ˆμ •λ˜μ–΄ μžˆλ”λΌκ΅¬μš”.

κ·Έλž˜μ„œ 객체 κ°„ μ—­ν•  뢄리와 κ΄€λ ¨λœ λ¦¬λ·°λŠ” 3단계에 λΆ€νƒλ“œλ¦΄κ²Œμš”.

κ·Έ μ™Έμ—λŠ” νŽΈν•˜κ²Œ λ¦¬λ·°ν•΄μ£Όμ‹œλ©΄ κ³ λ§™κ² μŠ΅λ‹ˆλ‹€!

참고둜, λ³Έ PRμ—λŠ” 1단계에 ν•΄λ‹Ήν•˜λŠ” μ½”λ“œλ§Œ ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

리뷰 잘 λΆ€νƒλ“œλ €μš”!

@zeus6768 zeus6768 self-assigned this Sep 6, 2024
@Mingyum-Kim Mingyum-Kim self-requested a review September 7, 2024 07:25
Copy link

@Mingyum-Kim Mingyum-Kim left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” 제우슀 !

κΌΌκΌΌν•˜κ²Œ λ―Έμ…˜ μˆ˜ν–‰ν•΄μ£Όμ…¨λ„€μš” πŸ‘ 적절히 클래슀 뢄리도 ν•΄μ£Όμ–΄μ„œ μ‰½κ²Œ 읽을 수 μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

μ½”λ“œ μ„€κ³„λ‚˜ HTTP에 λŒ€ν•œ 심도 μžˆλŠ” μ΄μ•ΌκΈ°λŠ” λ‹€μŒ λ―Έμ…˜μ„ μ§„ν–‰ν•œ 후에 재미있게 λ‚˜λˆ λ³΄λ©΄ 쒋을 것 κ°™μ•„μš”. μš”λ²ˆ λ‹¨κ³„μ—μ„œλŠ” κ°€λ³κ²Œ μ§ˆλ¬Έμ΄λ‚˜ μ°Έκ³ ν•˜λ©΄ 쒋을 뢀뢄을 리뷰둜 λ‚¨κ²¨λ†“μ•˜μŠ΅λ‹ˆλ‹€!

수고 λ§ŽμœΌμ…¨μ–΄μš”. 즐거운 주말 λ˜μ„Έμš”! πŸ˜€

Comment on lines 52 to 61
if (!filename.isEmpty()) {
final var classLoader = getClass().getClassLoader();
final var url = classLoader.getResource("static/" + filename);
final var resourcePath = Path.of(url.getPath());

responseBody = Files.readString(resourcePath);

} else {
responseBody = "Hello world!";
}

Choose a reason for hiding this comment

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

responseBodyλ₯Ό "Hello,World!"둜 λ””ν΄νŠΈλ‘œ κ³ μ •ν•˜κ³ , 파일 이름이 μžˆλŠ” 경우 λ‹€λ₯Έ 처리λ₯Ό ν•΄μ£Όλ©΄else` ꡬ문을 μ œκ±°ν•  수 μžˆκ² λ„€μš” !

final var _protocolVersion = requestLineSplit[2];

final var filename = path.replace("/", "");
final var request = new HttpRequest(inputStream);

Choose a reason for hiding this comment

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

객체지ν–₯ πŸ‘

Comment on lines 41 to 45
var line = reader.readLine();
while (line != null) {
body.add(line);
line = reader.readLine();
}

Choose a reason for hiding this comment

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

while 쑰건문 λ‚΄μ—μ„œ readLine()을 μˆ˜ν–‰ν•˜λŠ” λ°©μ‹μœΌλ‘œ ν•˜λ©΄ 쒋을 것 κ°™μ•„μš” !

Comment on lines +5 to +6
public static final String TEXT_HTML = "text/html";
public static final String TEXT_CSS = "text/css";

Choose a reason for hiding this comment

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

CSS와 HTML에 λŒ€ν•΄ λ‹€λ₯Έ MediaType을 전달해주면 μ–΄λ–€ λ™μž‘ λ°©μ‹μ˜ 차이가 μžˆλ‚˜μš”?

Copy link
Member Author

Choose a reason for hiding this comment

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

μ„œλ²„κ°€ CSS νŒŒμΌμ„ μ‘λ‹΅λ©΄μ„œ Content-Type의 값을 text/html둜 보내면 λΈŒλΌμš°μ €κ°€ html 파일둜 μΈμ‹ν•˜κΈ° λ•Œλ¬Έμ— CSS λ™μž‘ν•˜μ§€ μ•Šμ•„μš”. λΈŒλΌμš°μ €μ— CSS νŒŒμΌμ„ ν…μŠ€νŠΈλ‘œ 좜λ ₯ν•˜κ²Œ λ©λ‹ˆλ‹€.

λ―Έμ…˜μ„ μ§„ν–‰ν•˜λ©΄μ„œ μš”μ²­μ˜ Accept 헀더λ₯Ό 톡해 보고 μ‘λ‹΅μ˜ Content-Type을 κ²°μ •ν•˜λŠ” 둜직이 듀어가도둝 κ΅¬ν˜„ν•  μƒκ°μ΄μ—μš” πŸ˜„

private String extension(final String path) {
final var index = path.lastIndexOf(".");
return path.substring(index + 1);
private String mapResource(final HttpRequest request) throws IOException {

Choose a reason for hiding this comment

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

ν†°μΊ£μ˜ ServletContainerκ°€ ν•˜λŠ” 역할을 μš” λ©”μ„œλ“œκ°€ ν•΄μ£Όκ³  μžˆλ„€μš”!
좔후에 ν†°μΊ£μ˜ λ™μž‘ 방식을 μ°Έκ³ ν•΄ λ¦¬νŒ©ν† λ§ν•΄λ³΄λ©΄ μž¬λ°Œμ„ 것 κ°™μ•„μš”~

Copy link
Member Author

Choose a reason for hiding this comment

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

λͺ°λžλ˜ κ°œλ…μΈλ° μ•Œλ €μ€˜μ„œ κ³ λ§ˆμ›Œμš”!

ν•΄λ‹Ή ν‚€μ›Œλ“œλ‘œ κ³΅λΆ€ν•΄λ³Όκ²Œμš” πŸ‘

Copy link
Member Author

@zeus6768 zeus6768 left a comment

Choose a reason for hiding this comment

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

주말 잘 λ³΄λ‚΄μ…¨λ‚˜μš” μ•ˆλ‚˜ πŸ‘‹

리뷰 덕뢄에 κ³΅λΆ€ν•˜κΈ° 쒋은 ν‚€μ›Œλ“œ μ•Œμ•„κ°‘λ‹ˆλ‹€ πŸ™‡β€β™‚οΈ

μΆ”κ°€ μ½”λ©˜νŠΈ μžˆλ‹€λ©΄ 해주셔도 μ’‹κ³ , Approve ν•΄μ£Όμ‹œλ©΄ λΉ λ₯΄κ²Œ 2단계 κ΅¬ν˜„ν•΄ μ˜¬κ²Œμš”!

Comment on lines +5 to +6
public static final String TEXT_HTML = "text/html";
public static final String TEXT_CSS = "text/css";
Copy link
Member Author

Choose a reason for hiding this comment

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

μ„œλ²„κ°€ CSS νŒŒμΌμ„ μ‘λ‹΅λ©΄μ„œ Content-Type의 값을 text/html둜 보내면 λΈŒλΌμš°μ €κ°€ html 파일둜 μΈμ‹ν•˜κΈ° λ•Œλ¬Έμ— CSS λ™μž‘ν•˜μ§€ μ•Šμ•„μš”. λΈŒλΌμš°μ €μ— CSS νŒŒμΌμ„ ν…μŠ€νŠΈλ‘œ 좜λ ₯ν•˜κ²Œ λ©λ‹ˆλ‹€.

λ―Έμ…˜μ„ μ§„ν–‰ν•˜λ©΄μ„œ μš”μ²­μ˜ Accept 헀더λ₯Ό 톡해 보고 μ‘λ‹΅μ˜ Content-Type을 κ²°μ •ν•˜λŠ” 둜직이 듀어가도둝 κ΅¬ν˜„ν•  μƒκ°μ΄μ—μš” πŸ˜„

private String extension(final String path) {
final var index = path.lastIndexOf(".");
return path.substring(index + 1);
private String mapResource(final HttpRequest request) throws IOException {
Copy link
Member Author

Choose a reason for hiding this comment

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

λͺ°λžλ˜ κ°œλ…μΈλ° μ•Œλ €μ€˜μ„œ κ³ λ§ˆμ›Œμš”!

ν•΄λ‹Ή ν‚€μ›Œλ“œλ‘œ κ³΅λΆ€ν•΄λ³Όκ²Œμš” πŸ‘

Copy link

@Mingyum-Kim Mingyum-Kim left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” 제우슀 ~

이번 λ‹¨κ³„μ—μ„œλŠ” λΉ λ₯΄κ²Œ λ„˜μ–΄κ°€κ³  λ‹€μŒ λ¦¬λ·°μ—μ„œ μž¬λ―ΈμžˆλŠ” 이야기 많이 ν•΄λ΄μš”.
λ°”μ˜κ² μ§€λ§Œ νž˜λ‚΄μ‹œκΈ° λ°”λžλ‹ˆλ‹€! πŸ‘πŸ‘πŸ‘

@Mingyum-Kim Mingyum-Kim merged commit badca13 into woowacourse:zeus6768 Sep 9, 2024
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.

3 participants