Repository navigation
core: parse task and job IDs from Location header - #4895
Merged
Merged
Conversation
Contributor
Author
|
This is working towards #4893 |
divergentdave
approved these changes
Oct 13, 2026
| ) | ||
| })?; | ||
|
|
||
| let mut components = location.split("/").collect::<Vec<_>>().into_iter().rev(); |
Collaborator
There was a problem hiding this comment.
This can be simplified:
Suggested change
| let mut components = location.split("/").collect::<Vec<_>>().into_iter().rev(); | |
| let mut components = location.rsplit('/'); |
Contributor
Author
There was a problem hiding this comment.
Nice! This saves an allocation, too.
| let mut next_component = || { | ||
| components | ||
| .next() | ||
| .ok_or(HeaderMapExtError::MalformedLocationHeader( |
Collaborator
There was a problem hiding this comment.
We can avoid a clone on the happy path:
Suggested change
| .ok_or(HeaderMapExtError::MalformedLocationHeader( | |
| .ok_or_else(|| HeaderMapExtError::MalformedLocationHeader( |
Comment on lines
+859
to
+868
| // Malformed middle component | ||
| assert_matches!( | ||
| header_map(&[( | ||
| http::header::LOCATION, | ||
| "/tasks/ii_NZYRUHjMI9YCQMmD2ZJNUpLiVz1KHEg-ANpWWnG4/malformed/_Ruk_njErWlidLK2YtFxPA" | ||
| )]) | ||
| .ids_from_collection_job_location() | ||
| .unwrap_err(), | ||
| HeaderMapExtError::MalformedLocationHeader(..) | ||
| ); |
Collaborator
There was a problem hiding this comment.
nit: We're missing a test case where the tasks component is replaced with something else.
tgeoghegan
force-pushed
the
timg/parse-ids-in-location
branch
from
October 13, 2026 15:50
aabc80b to
31baf2b
Compare
tgeoghegan
enabled auto-merge (squash)
October 13, 2026 15:50
Moving toward server-selected resource identifiers means that HTTP clients need to parse resource identifiers from URIs provided by servers in `Location` HTTP headers. This adds an extension trait `HeaderMapExt` with method `ids_from_collection_job_location`. It finds a `Location` header and parses its value, extracting the task and collection job IDs. In the future, we'll need to do this for aggregate shares and aggregation jobs, too, at which point we can make this method generic over types that can be parsed from Base64URL. But for now, we specialize to collection jobs.
tgeoghegan
force-pushed
the
timg/parse-ids-in-location
branch
from
October 13, 2026 16:04
31baf2b to
ea8e614
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moving toward server-selected resource identifiers means that HTTP clients need to parse resource identifiers from URIs provided by servers in
LocationHTTP headers.This adds an extension trait
HeaderMapExtwith methodids_from_collection_job_location. It finds aLocationheader and parses its value, extracting the task and collection job IDs.In the future, we'll need to do this for aggregate shares and aggregation jobs, too, at which point we can make this method generic over types that can be parsed from Base64URL. But for now, we specialize to collection jobs.