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

Fix HTTP HEAD method #2366

Merged
merged 1 commit into from
Sep 19, 2023
Merged

Fix HTTP HEAD method #2366

merged 1 commit into from
Sep 19, 2023

Conversation

chenBright
Copy link
Contributor

@chenBright chenBright commented Aug 31, 2023

What problem does this PR solve?

Issue Number: fix #764

Problem Summary:
解析HTTP HEAD请求的回包时,如果回包header中content-length不为0或者transfer-encoding为shunked,on_headers_complete未返回1,则parser会继续解析body。但是HTTP回包是不包含body部分的,就导致会parser一直等到rpc超时。

/* Here we call the headers_complete callback. This is somewhat
* different than other callbacks because if the user returns 1, we
* will interpret that as saying that this message has no body. This
* is needed for the annoying case of recieving a response to a HEAD
* request.
*
* We'd like to use CALLBACK_NOTIFY_NOADVANCE() here but we cannot, so
* we have to simulate it by handling a change in errno below.
*/

if (settings->on_headers_complete) {
switch (settings->on_headers_complete(parser)) {
case 0:
break;
case 1:
parser->flags |= F_SKIPBODY;
break;
default:
SET_ERRNO(HPE_CB_headers_complete);
return p - data; /* Error */
}
}

What is changed and the side effects?

Changed:

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.(请遵循贡献者准则).

@chenBright chenBright added the bug the code does not work as expected label Aug 31, 2023
@wwbmmm
Copy link
Contributor

wwbmmm commented Sep 7, 2023

LGTM
另外标题中的DEAD是HEAD误写了,还是有什么特别的含义?

@chenBright chenBright changed the title Fix HTTP DEAD method Fix HTTP HEAD method Sep 7, 2023
@chenBright
Copy link
Contributor Author

LGTM 另外标题中的DEAD是HEAD误写了,还是有什么特别的含义?

笔误。标题和commit message都改过来了

@wwbmmm wwbmmm merged commit fcb483e into apache:master Sep 19, 2023
@chenBright chenBright deleted the http_head branch September 20, 2023 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug the code does not work as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

brpc http client head请求问题
2 participants