enhancement(http_client source): add support for request body
Summary
This PR allows a request body to be sent via the http_client source with additional support for VRL.
Vector configuration
As a raw string:
sources:
api:
type: http_client
endpoint: https://foobar.com/api/audit/search
method: POST
headers:
Accept:
- application/json
auth:
strategy: bearer
token: ${API_TOKEN}
body: |
{
"searchStatements": [{
"column": "auditAction",
"operator": "=",
"value": "DELETE"
}]"
}
with VRL:
sources:
api:
type: http_client
endpoint: https://foobar.com/api/audit/search
method: POST
headers:
Accept:
- application/json
auth:
strategy: bearer
token: ${API_TOKEN}
body:
value: |
encode_json({
"searchStatements": [{"column": "auditAction", "operator": "=", "value": "DELETE"}],
"timestamp": now()
})
type: vrl
How did you test this PR?
Change Type
- [ ] Bug fix
- [x] New feature
- [ ] Non-functional (chore, refactoring, docs)
- [ ] Performance
Is this a breaking change?
- [ ] Yes
- [x] No
Does this PR include user facing changes?
- [x] Yes. Please add a changelog fragment based on our guidelines.
- [ ] No. A maintainer will apply the
no-changeloglabel to this PR.
References
- Closes #14758
Notes
- Please read our Vector contributor resources.
- Do not hesitate to use
@vectordotdev/vectorto reach out to us regarding this PR. - Some CI checks run only after we manually approve them.
- We recommend adding a
pre-pushhook, please see this template. - Alternatively, we recommend running the following locally before pushing to the remote branch:
make fmtmake check-clippy(if there are failures it's possible some of them can be fixed withmake clippy-fix)make test
- We recommend adding a
- After a review is requested, please avoid force pushes to help us review incrementally.
- Feel free to push as many commits as you want. They will be squashed into one before merging.
- For example, you can run
git merge origin masterandgit push.
- If this PR introduces changes Vector dependencies (modifies
Cargo.lock), please runmake build-licensesto regenerate the license inventory and commit the changes (if any). More details here.
Hi @pront,
Have added a note about the default content type in 64721f7d9.
I think the current unit tests should provide enough coverage, so will leave the integration test suite as-is. Failing docs check should be addressed by 83a4621f8 🙏
hey @thomasqueirozb, any blockers on this one? would like to merge before any drift occurs 🙏
Hi @benjamin-awd. We missed this one, sorry. Since pront gave the approval and had even queued it I'll make an exception and include it in the release tomorrow since it should've been merged quite some time ago.