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

Semantic Status Code - modify on_request response from 200 to 204 in plugin/in_http #2640

Merged
merged 3 commits into from
Oct 9, 2019
Merged

Semantic Status Code - modify on_request response from 200 to 204 in plugin/in_http #2640

merged 3 commits into from
Oct 9, 2019

Conversation

achinchen
Copy link
Contributor

The reason about this PR:

I used fluentd service and figured that 200 response with empty string is a little bit not precise.
According to rfc7231, 204 is more proper status code.

a 204 status code is commonly used with document editing interfaces corresponding to a "save" action

What this PR does / why we need it:

  • For more semantic status code
  • Add test for this change in test_in_http
  • Fix typo in test_in_http

Signed-off-by: Chin <[email protected]>

1. Modify response status code in in_http
2. Add test_response_without_empty_img in test_in_http
3. Fix typo of test_response_with_empty_img in test_in_http
Copy link
Member

@ganmacs ganmacs left a comment

Choose a reason for hiding this comment

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

https://tools.ietf.org/html/rfc7231#section-6.3.1

a 200 response always has a payload,
though an origin server MAY generate a payload body of zero length.
If no payload is desired, an origin server ought to send 204 (No
Content) instead

Right. According to RFC, 204 seems better than 200 when sending no payload. LGTM.

But this is breaking change, so it may be better just changing a success message to the not empty payload(e.g. "200 OK") to avoid breaking change.
@repeatedly What do you think of this?

@repeatedly
Copy link
Member

Yeah, we can't judge this change is safe for existing users.
So following step is better:

  • Add bool option to change status code, like use_204_response.
  • Change default behaviour and remove option at fluentd v2.

Signed-off-by: Chin <[email protected]>

1. Add use_204_response flag to avoid breaking change happened in in_http
2. Modify test to keep testing the edge
@achinchen achinchen requested a review from ganmacs October 8, 2019 14:52
@achinchen
Copy link
Contributor Author

Thanks for review.
I did a little bit change which avoids the breaking change.
Please re-review it.
If we're not on the same page, just let me know. 😊

@@ -140,7 +140,7 @@ def close
super
end

def on_request(path_info, params)
def on_request(path_info, params, use_204_response=false)
Copy link
Member

Choose a reason for hiding this comment

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

How do users set use_204_response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I think that is my misunderstanding.
I fixed it and add config_param in in_http.

This is my first time to PR with Ruby.
let me know if anything not suitable.
Thanks for review.

Signed-off-by: chin <[email protected]>

1.Add config_param use_204_response in in_http
2.Add test_response_use_204_response in test_in_http
@achinchen achinchen requested a review from ganmacs October 9, 2019 04:53
@repeatedly repeatedly merged commit 02c1e2b into fluent:master Oct 9, 2019
@repeatedly
Copy link
Member

Thanks!

repeatedly added a commit that referenced this pull request Oct 25, 2019
Semantic Status Code - modify on_request response from 200 to 204 in plugin/in_http
Signed-off-by: Masahiro Nakagawa <[email protected]>
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