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 HttpResponse error #1620

Merged
merged 2 commits into from
Dec 3, 2021
Merged

Conversation

jl2005
Copy link

@jl2005 jl2005 commented Dec 1, 2021

When an incorrect HTTP request is received, the existing code returns an HttpRequest, which should actually return an HttpResponse.
before fixing:

# curl 127.0.0.1:8010/v1/queue/stop\ 1  -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8010 (#0)
> GET /v1/queue/stop 1 HTTP/1.1
> Host: 127.0.0.1:8010
> User-Agent: curl/7.64.1
> Accept: */*
>
GET / HTTP/1.1
Host: 127.0.0.1:58674
Accept: */*
User-Agent: brpc/1.0 curl/7.0

* Closing connection 0

After modification:

# curl 127.0.0.1:8010/v1/queue/stop\ 1  -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8010 (#0)
> GET /v1/queue/stop 1 HTTP/1.1
> Host: 127.0.0.1:8010
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 400 Bad Request
* no chunk, no close, no size. Assume close to signal end
<
* Closing connection 0

@jl2005
Copy link
Author

jl2005 commented Dec 1, 2021

@@ -1146,13 +1146,13 @@ ParseResult ParseHttpMessage(butil::IOBuf *source, Socket *socket,
return MakeParseError(PARSE_ERROR_NOT_ENOUGH_DATA);
}
// Send 400 back.
butil::IOBuf bad_req;
butil::IOBuf bad_resp;
Copy link
Member

Choose a reason for hiding this comment

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

The variable name should be bad_req, which indicates that the response content is 'Bad Request', rather than a 'bad' response.

Copy link
Member

Choose a reason for hiding this comment

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

Then a simple resp maybe better.

Copy link
Author

Choose a reason for hiding this comment

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

@wasphin I have modified.

Copy link
Member

Choose a reason for hiding this comment

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

Not a member.

@jl2005 jl2005 requested a review from chenzhangyi December 3, 2021 03:25
Copy link
Author

@jl2005 jl2005 left a comment

Choose a reason for hiding this comment

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

Already fixed

@@ -1146,13 +1146,13 @@ ParseResult ParseHttpMessage(butil::IOBuf *source, Socket *socket,
return MakeParseError(PARSE_ERROR_NOT_ENOUGH_DATA);
}
// Send 400 back.
butil::IOBuf bad_req;
butil::IOBuf bad_resp;
Copy link
Author

Choose a reason for hiding this comment

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

@wasphin I have modified.

@chenzhangyi chenzhangyi merged commit eeef69d into apache:master Dec 3, 2021
@chenzhangyi
Copy link
Member

Merged, thanks for your contribution.

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