NaoyaFukuma / webserv

This is when you finally understand why a URL starts with HTTP
3 stars 0 forks source link

大きいbodyの扱いをRFCで確認する #146

Open Chanmachan opened 1 year ago

Chanmachan commented 1 year ago

Overview

Please provide an overview of the issue you are creating. ex) I want to adapt the style of the header.

Purpose

Describe the purpose of this issue ex) To style it.

Task

Break down and manage your tasks.

Chanmachan commented 1 year ago

勘違いしてました;;

Transfer-Encoding ヘッダを包含する どのメッセージにも, Content-Length ヘッダを送信してはならない。

Chanmachan commented 1 year ago

受信したメッセージが[ Transfer-Encoding, Content-Length ]の両ヘッダを伴う場合、 Transfer-EncodingContent-Length を上書きする。 そのようなメッセージは[ 要請密入応答分割 ]を遂行する試みを指示しているかもしれないので、[ エラーとして取り扱われるべき.である ]。 送信者は,[ そのようなメッセージを下流へ回送する ]に先立って[ 受信された Content-Length ヘッダ ]を除去しなければならない。

Chanmachan commented 1 year ago

メッセージ本体転送符号法チャンク化が利用されていて,符号化を終了させる[ サイズゼロのチャンク ]が受信されなかったとき。 Content-Length が利用されていて,その値より[ 受信されたメッセージ本体の(オクテット数による)サイズ ]が小さいとき。 チャンク化転送符号法Content-Length も持たない応答は,[ 接続の closure ]により終了されるので、[ ヘッダ節は全て受信された ]限りにおいて,[ 受信されたメッセージ本体のオクテット数 ]に関わらず 完全と見なされる。

A user agent that sends a request containing a message body MUST send a valid Content-Length header field if it does not know the server will handle HTTP/1.1 (or later) requests; such knowledge can be in the form of specific user configuration or by remembering the version of a prior received response. If the final response to the last request on a connection has been completely received and there remains additional data to read, a user agent MAY discard the remaining data or attempt to determine if that Fielding & Reschke Standards Track [Page 33] RFC 7230 HTTP/1.1 Message Syntax and Routing June 2014 data belongs as part of the prior response body, which might be the case if the prior message's Content-Length value is incorrect. A client MUST NOT process, cache, or forward such extra data as a separate response, since such behavior would be vulnerable to cache poisoning.

Chanmachan commented 1 year ago

最後にcontent-length以上のボディがきたら、今の実装だと次のリクエスト扱いになってボディの先頭が無効なメソッドとして501にセットされてしまう。それを防ぐために、そういうときにはそのボディ以降の文字列をGetWordしてそれが有効なものではない場合は400を返すようにする? でもそれだと

Chanmachan commented 1 year ago

その前にAssertAllowMethod?で405がセットされるのが問題。configは変えて https://speeding-meadow-328466.postman.co/workspace/My-Workspace~406dca8f-3ab0-425b-8b1b-e7ebdde0b94a/request/27714252-de3e8ac6-e56e-4872-b1ba-7506e734afa4