-
Notifications
You must be signed in to change notification settings - Fork 2
FEAT: Support for forwarding response headers from http task #36
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds support for forwarding HTTP response headers from the HTTP task to downstream tasks via the context mechanism. Headers are automatically stored with an http-header- prefix (e.g., http-header-Content-Type) and can be accessed using context variables like {{ context "http-header-Content-Type" }}.
Changes:
- Updated placeholder regex to support hyphens in context variable names
- HTTP task now stores all response headers in record context with
http-header-prefix - Added documentation and examples for accessing response headers
- Added integration test demonstrating header access in context_test.yaml
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/pkg/config/config.go | Updated placeholderRegex from ([a-zA-Z0-9_]+?) to ([a-zA-Z0-9_-]+?) to support hyphens in context keys |
| internal/pkg/pipeline/task/http/http.go | Added logic to store all HTTP response headers in record context with http-header- prefix |
| internal/pkg/pipeline/task/http/README.md | Added documentation section explaining header forwarding feature with examples |
| test/pipelines/context_test.yaml | Added test cases accessing http-header-Content-Type and http-header-Age headers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…at_header_ctx_support
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| if err := json.Unmarshal(document, &data); err != nil { | ||
| return nil, err | ||
| // If the document is not valid JSON, treat it as a raw string | ||
| data = string(document) |
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 certain cases where record is non json (e.g. text data, html).
JQ like this was failing:
- name: transform_with_context_jq
type: jq
path: |
{
"headers_content_type": "{{ context "http-header-Content-Type" }}",
"headers_cookie": "{{ context "http-header-Set-Cookie" }}",
"original_data": .
}
Reason : Since data is non json, Marshalling would return error.
Although we wont be anyway able to apply jq selector on it anyway, but this change gives capability to support the complete response, and make the above JQ work.
Description
Support for forwarding response headers from http task, and modification to jq task for non standard json record.
Why:
(Note: Although we wont be anyway able to apply jq selector on it anyway, but this change gives capability to support selection of the complete response, and make the above JQ work.)
Use case:
Testing:
Done on test/pipelines/context_test.yaml file
Types of changes
Checklist