Skip to content

feat: Implement HTTP/1.1 request parser with pipeline integration#70

Merged
jisung-02 merged 1 commit into
mainfrom
14-http-req-parser
Dec 7, 2025
Merged

feat: Implement HTTP/1.1 request parser with pipeline integration#70
jisung-02 merged 1 commit into
mainfrom
14-http-req-parser

Conversation

@jisung-02
Copy link
Copy Markdown
Owner

@jisung-02 jisung-02 commented Dec 7, 2025

  • Add request.gleam with HttpVersion and ParsedRequest types
  • Add url.gleam with percent-encoding/decoding (RFC 3986)
  • Add parser.gleam for request line, headers, and body parsing
  • Add builder.gleam for HTTP request serialization
  • Add stage.gleam with decode/encode stages and Protocol registration
  • Support Content-Length and Chunked Transfer-Encoding body parsing
  • Support HTTP pipelining with remaining_bytes return
  • Integrate with gleam_http library types (Method, Request)
  • Add comprehensive unit tests for all modules (677 tests passing)

.github/pull_request_template.md

🎯 변경 사항

📋 체크리스트

  • gleam format 실행 완료
  • gleam check 통과
  • 테스트 추가/수정 완료
  • 문서 업데이트 완료
  • CHANGELOG.md 업데이트 (필요시)

🧪 테스트 방법

🤖 CodeRabbit 리뷰 요청사항

  • 성능 최적화 검토
  • 에러 처리 검증
  • 타입 안전성 확인
  • API 설계 리뷰

📸 스크린샷/데모


참고: 댓글에 @coderabbitai 다시 리뷰해줘라고 작성하면 전체 재리뷰를 요청할 수 있습니다.

Summary by CodeRabbit

릴리스 노트

  • New Features

    • HTTP/1.0 및 HTTP/1.1 요청 파싱 및 직렬화 지원 추가
    • 청크 전송 인코딩 및 HTTP 파이프라이닝 지원
    • URL 인코딩/디코딩 및 쿼리 문자열 처리 기능 제공
    • HTTP 프로토콜 단계에서 요청 메타데이터 관리 기능 추가
  • Tests

    • HTTP 파서, 빌더, 요청 모듈, 프로토콜 단계 및 URL 유틸리티에 대한 포괄적인 테스트 스위트 추가

✏️ Tip: You can customize this high-level summary in your review settings.

  - Add request.gleam with HttpVersion and ParsedRequest types
  - Add url.gleam with percent-encoding/decoding (RFC 3986)
  - Add parser.gleam for request line, headers, and body parsing
  - Add builder.gleam for HTTP request serialization
  - Add stage.gleam with decode/encode stages and Protocol registration
  - Support Content-Length and Chunked Transfer-Encoding body parsing
  - Support HTTP pipelining with remaining_bytes return
  - Integrate with gleam_http library types (Method, Request)
  - Add comprehensive unit tests for all modules (677 tests passing)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

이 PR은 Gleam으로 구현한 완전한 HTTP/1.1 요청 처리 시스템을 도입합니다. 요청 데이터 타입 정의, 파싱 로직, 직렬화 로직, 프로토콜 스테이지 통합, URL 인코딩/디코딩을 포함하며, 광범위한 테스트 스위트로 검증됩니다.

Changes

코호트 / 파일 변경 요약
HTTP 요청 데이터 구조
src/aether/protocol/http/request.gleam
HttpVersion 열거형(Http10, Http11)과 ParsedRequest 타입 도입. 요청 생성(new, get, post, put, delete), 수정(set_version, set_body, set_header, add_header), 접근(get_header, content_length, is_chunked, host, content_type)과 URI 유틸리티(path, query) 제공. 대소문자 구분 없는 헤더 처리 구현
HTTP 요청 파싱
src/aether/protocol/http/parser.gleam
ParseError 타입과 함께 HTTP/1.1 요청 파싱 엔진 추가. parse_request가 요청 라인, 헤더, 본문(Content-Length 및 청크 인코딩 지원)을 파싱. 강건한 에러 처리와 hex 파싱 유틸리티 포함. to_http_request로 ParsedRequest를 gleam_http 요청으로 변환
HTTP 요청 빌드
src/aether/protocol/http/builder.gleam
ParsedRequest를 HTTP 바이트로 직렬화하는 빌드 함수들 추가. build_request로 완전한 HTTP 메시지 생성, build_chunked_request로 청크 인코딩 지원. gleam_http Request에서 변환하는 from_http_request 제공
HTTP 프로토콜 스테이지
src/aether/protocol/http/stage.gleam
파이프라인 프레임워크와 통합하는 decode/encode 스테이지 구현. HttpRequestData 타입으로 메타데이터를 통한 요청 상태 관리. HTTP 파이프라이닝 지원(remaining_bytes). 프로토콜 레지스트리 등록과 편의 헬퍼 함수들 제공
URL 인코딩/디코딩
src/aether/protocol/http/url.gleam
UrlError 타입과 퍼센트 인코딩/디코딩(percent_encode, percent_decode) 함수. RFC 3986 규칙 준수. 쿼리 문자열 파싱/구성(parse_query_string, build_query_string) 유틸리티 포함
빌더 테스트
test/aether/protocol/http/builder_test.gleam
요청 라인, 헤더, 본문 빌드와 gleam_http 변환, 청크 인코딩 등 22개의 테스트 케이스 추가
파서 테스트
test/aether/protocol/http/parser_test.gleam
GET/POST/PUT/DELETE 메서드, HTTP 버전, 헤더 정규화, 청크 인코딩, 파이프라이닝, 에러 시나리오 등 29개의 파서 테스트 추가
요청 타입 테스트
test/aether/protocol/http/request_test.gleam
생성자, 수정자, 접근자, 변환, 헤더 처리 등 포괄적인 단위 테스트 추가
스테이지 테스트
test/aether/protocol/http/stage_test.gleam
decode/encode 스테이지, 라운드트립, 프로토콜 설정, 레지스트리, 헬퍼 함수 검증 23개 테스트 추가
URL 테스트
test/aether/protocol/http/url_test.gleam
퍼센트 인코딩/디코딩, 유니코드, 쿼리 문자열 파싱/구성 등 포괄적인 테스트 추가

Sequence Diagram

sequenceDiagram
    participant Raw as Raw HTTP Bytes
    participant Parser as HTTP Parser
    participant PR as ParsedRequest
    participant Stage as HTTP Stage
    participant Meta as Metadata
    participant Builder as HTTP Builder
    participant Out as Output Bytes

    Raw->>Parser: parse_request(bytes)
    Parser->>Parser: parse_request_line()
    Parser->>Parser: parse_headers()<br/>(lowercase keys)
    Parser->>Parser: parse_body()<br/>(Content-Length or Chunked)
    Parser->>PR: construct ParsedRequest
    PR->>Stage: decode() stage
    Stage->>Stage: convert to gleam_http Request
    Stage->>Meta: store HttpRequestData<br/>(request + remaining_bytes)
    Meta->>Stage: get request for encoding
    Stage->>Builder: encode() stage
    Builder->>Builder: build_request_line()
    Builder->>Builder: build_headers()
    Builder->>Builder: handle Content-Length/<br/>Transfer-Encoding
    Builder->>Out: build complete HTTP bytes
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 분

특별히 검토가 필요한 영역:

  • 재귀적 파싱 로직 (parser.gleam): do_parse_headers, do_parse_chunks, do_parse_hex 등의 재귀 함수에서 종료 조건, 누적기(accumulator) 패턴, BitArray 슬라이싱이 올바르게 처리되는지 확인 필요
  • Result/Option 체이닝: 파서와 빌더에서 Result 타입이 일관되게 처리되고 있는지, 에러 전파가 적절한지 검증 필요
  • FFI 상호작용 (stage.gleam): coerce_via_hd 외부 함수를 통한 Dynamic 타입 변환의 안전성 확인. 타입 안전성 보장 확인 필요
  • 대소문자 정규화: 헤더 이름의 소문자 변환이 모든 경로에서 일관되게 적용되는지 확인 (파싱, 빌드, 조회 등)
  • 청크 인코딩 구현: build_chunked_bodyparse_chunked_body의 hex 인코딩/디코딩이 RFC 7230을 정확히 따르는지 검증
  • URL 인코딩: RFC 3986 unreserved 문자 집합 정의의 정확성과 퍼센트 시퀀스 처리의 완전성 확인
  • 파이프라이닝 지원: HTTP 파이프라이닝에서 remaining_bytes 처리가 상태 누수 없이 정확하게 이루어지는지 확인
  • 라운드트립 일관성: 파서와 빌더 간 상호 호환성 보장 (특히 특수 문자, 헤더 순서, Content-Length 자동 삽입)

Poem

HTTP의 바이트들이 춤을 추고 🌊
파서의 손길로 구조화되며,
헤더와 본문이 질서정연하게 정렬되고,
청크는 16진 십자가에 걸려,
스테이지를 거쳐 새로운 메시지로 태어난다 ✨


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between e1b276b and 879d00a.

📒 Files selected for processing (10)
  • src/aether/protocol/http/builder.gleam (1 hunks)
  • src/aether/protocol/http/parser.gleam (1 hunks)
  • src/aether/protocol/http/request.gleam (1 hunks)
  • src/aether/protocol/http/stage.gleam (1 hunks)
  • src/aether/protocol/http/url.gleam (1 hunks)
  • test/aether/protocol/http/builder_test.gleam (1 hunks)
  • test/aether/protocol/http/parser_test.gleam (1 hunks)
  • test/aether/protocol/http/request_test.gleam (1 hunks)
  • test/aether/protocol/http/stage_test.gleam (1 hunks)
  • test/aether/protocol/http/url_test.gleam (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@jisung-02 jisung-02 merged commit 6e4f3dd into main Dec 7, 2025
0 of 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.

1 participant