-
Notifications
You must be signed in to change notification settings - Fork 19
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(influxdb2/client): Send Content-Type headers #30
Conversation
@@ -24,6 +24,8 @@ class DefaultApi | |||
DEFAULT_TIMEOUT = 10 | |||
DEFAULT_REDIRECT_COUNT = 10 | |||
|
|||
HEADER_CONTENT_TYPE = 'Content-Type'.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 😎
_post(payload, uri, headers: headers.merge({HEADER_CONTENT_TYPE => 'text/plain'})) | ||
end | ||
|
||
def _post(payload, uri, limit: @max_redirect_count, headers: {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was your rationale behind creating two separate methods, _post_json
and _post_text
which are identical aside from content-type? keeping the original _post
method and exposing a content_type
named argument w/ a reasonable default (e.g. application/json
) might also be worth considering? (would also provide increased flexibility in allowing _post
consumers to provide different content-type headers alongside their payloads if that's ever deemed beneficial)
(i guess, on second thought, not introducing another argument dependency in favor of encapsulating the content-type-setting logic in this class is probably more robust but still curious to hear your thoughts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underlying _post
method is HTTP-centric so it warranted a higher-level headers
concept if we are to be introducing any additional headers. However, this introduced a minor inconvenience at the JSON-based call sites so I just added some helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ship ship ship 🚢
@bednar eta on when 1.2 will be released? |
@reefloretto We will release clients at next friday, but if it is necessary We could release it early. |
We recently started requiring
Content-Type
headers in InfluxDB 2.x API. This ensures the client is sending the appropriate headers.