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

Opt Content-Length in response to HEAD request #2469

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

chenBright
Copy link
Contributor

What problem does this PR solve?

Issue Number:

Problem Summary:

  1. Fix HTTP HEAD method #2366 修复了HEAD请求的问题,但是一般情况下http service不会设置Content-Length,响应就不会包括Content-Length,没有达到HEAD请求的预期。
  2. Fix duplicate content type #2319 保证了Content-Type在HttpHeader是唯一的,那么在解包的时候,就不需要设置两次Content-Type了。
    const std::string* content_type = http_message->header().GetHeader("content-type");
    if (content_type) {
    http_message->header().set_content_type(*content_type);
    http_message->header().RemoveHeader("content-type");
    }

What is changed and the side effects?

Changed:

  1. 当响应HEAD请求时,优先使用用户设置的Content-Length。如果用户没有设置Content-Length,则使用content的长度作为Content-Length的值。
  2. 删除HttpMessage::on_headers_complete中重复设置Content-Type的重复逻辑。

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@wwbmmm
Copy link
Contributor

wwbmmm commented Dec 19, 2023

LGTM

@chenBright
Copy link
Contributor Author

@wwbmmm @serverglen 这个PR应该可以合入了

@wwbmmm wwbmmm merged commit 68432ab into apache:master Jan 17, 2024
18 checks passed
@chenBright chenBright deleted the opt_content_length branch January 17, 2024 02:42
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