-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Filebeat] add encode form and decode ndjson to httpjson input #23521
[Filebeat] add encode form and decode ndjson to httpjson input #23521
Conversation
- support "application/x-www-form-urlencoded", url parameters are encoded and sent in the body - support "application/x-ndjson", json objects are decoded and returned in an array at root level
b63c0ee
to
0a4a44a
Compare
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
} | ||
|
||
func encodeAsJSON(trReq transformable) ([]byte, error) { | ||
if len(trReq.body()) == 0 { |
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.
❤️
for { | ||
var o interface{} | ||
err := dec.Decode(&o) | ||
if err == io.EOF { | ||
break | ||
} else if err != nil { | ||
return err | ||
} | ||
results = append(results, o) | ||
} |
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.
for { | |
var o interface{} | |
err := dec.Decode(&o) | |
if err == io.EOF { | |
break | |
} else if err != nil { | |
return err | |
} | |
results = append(results, o) | |
} | |
for dec.More() { | |
var o interface{} | |
if err := dec.Decode(&o); err != nil { | |
return err | |
} | |
results = append(results, o) | |
} |
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.
LGTM, feel free to ignore or not the suggested change.
What does this PR do?
request.encode_as
option. url parameters are encoded and sent inthe body
response.decode_as
option. json objects are decoded and returnedin an array at root level
Why is it important?
Some API endpoints require posting data as
application/x-www-form-urlencoded
Some API endpoints only return
application/x-ndjson
not jsonChecklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.