Skip to content

[Storage] Proposed HttpRange generated model proof-of-concept#3647

Draft
vincenttran-msft wants to merge 4 commits intoAzure:mainfrom
vincenttran-msft:vincenttran/http_range_header_model
Draft

[Storage] Proposed HttpRange generated model proof-of-concept#3647
vincenttran-msft wants to merge 4 commits intoAzure:mainfrom
vincenttran-msft:vincenttran/http_range_header_model

Conversation

@vincenttran-msft
Copy link
Member

@vincenttran-msft vincenttran-msft commented Feb 2, 2026

Currently when a range is specified, it must be in a specific format, and so we provided the format_page_range() function. Looking closer, this seems to be a common issue with any time range is specified, and we want to align with .NET's solution for this usage issue.

Usage would go from:
format_page_range(0, 512)? -> HttpRange::new(0, 512)
and would also allow this to be used generally (ie. not just page ranges but also like blob download etc.)

This proposal adds a more general-case approach, in which we would need the following:

  1. Generated HttpRange model with this impl. (or similar):
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HttpRange {
    pub offset: u64,
    pub length: Option<u64>,
}

impl fmt::Display for HttpRange {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self.length {
            Some(length) => write!(f, "bytes={}-{}", self.offset, self.offset + length - 1),
            None => write!(f, "bytes={}-", self.offset),
        }
    }
}
impl From<HttpRange> for String { ... }
impl From<HttpRange> for HeaderValue { ... }
  1. Generated code should take HttpRange instead of String

.tsp: Azure/azure-rest-api-specs#40095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant