RFC 9110 HTTP byte-range parser, resolver, serializer, response planner and audit toolkit for MoonBit.
let request = @range.parse_range("bytes=0-499,-100").unwrap()
println(@range.serialize_range(request))let request = @range.parse_range("bytes=500-,-100").unwrap()
let result = @range.resolve_byte_ranges(request, 1_000L).unwrap()bytes 0-499/1234
bytes 42-1233/*
bytes */1234moon run cmd/range-tool -- parse --range "bytes=0-499,-100"
moon run cmd/range-tool -- resolve --range "bytes=0-499,-100" --length 1000
moon run cmd/range-tool -- content-range --value "bytes 0-499/1000"
moon run cmd/range-tool -- accept-ranges --value "bytes, exampleunit"
moon run cmd/range-tool -- plan --range "bytes=0-99,900-" --length 1000
moon run cmd/range-tool -- audit --range "bytes=0-0,1-1,2-2,3-3" --length 1000
moon run cmd/range-tool -- stats --range "bytes=0-99"
moon run cmd/range-tool -- versionmoon run examples/parse --target wasm-gc
moon run examples/resolve --target js
moon run examples/content_range --target native
moon run examples/response_plan --target wasm-gcpowershell -ExecutionPolicy Bypass -File scripts/verify_all.ps1pub struct MultipartPartPlan {
range : ConcreteRange
content_range : ContentRangeValue
content_length : Int64
} derive(Eq, Debug)pub struct MultipartPlan {
boundary : String
content_type : String
parts : Array[MultipartPartPlan]
} derive(Eq, Debug)pub struct RangeRequest {
unit : RangeUnit
specs : Array[ByteRangeSpec]
raw_other_range_set : String?
} derive(Eq, Debug)pub struct ResolvedRangeSet {
satisfiable_ranges : Array[ConcreteRange]
unsatisfiable_count : Int
original_count : Int
} derive(Eq, Debug)pub(all) enum ResponsePlan {
Ignore
Unsatisfiable(Int64)
Single(ConcreteRange)
Multiple(Array[ConcreteRange])
} derive(Eq, Debug)fn audit_range_request(request : RangeRequest, raw_input? : String, representation_length? : Int64) -> AuditReportfn parse_accept_ranges_with_limits(input : String, limits : Limits) -> Result[AcceptRanges, RangeError]fn parse_content_range_with_limits(input : String, limits : Limits) -> Result[ContentRangeValue, RangeError]fn plan_byte_range_response(request : RangeRequest, representation_length : Int64, method_is_get : Bool, range_supported : Bool, apply_ranges : Bool) -> Result[ResponsePlan, RangeError]fn plan_multipart_ranges(ranges : Array[ConcreteRange], representation_length : Int64, boundary : String) -> Result[MultipartPlan, RangeError]fn range_error(stage : RangeErrorStage, kind : RangeErrorKind, offset : Int, context : String) -> RangeErrorfn range_request(unit : RangeUnit, specs : Array[ByteRangeSpec], raw_other_range_set? : String) -> RangeRequestfn resolve_byte_ranges(request : RangeRequest, representation_length : Int64) -> Result[ResolvedRangeSet, RangeError]fn resolved_range_set(ranges : Array[ConcreteRange], unsatisfiable_count : Int, original_count : Int) -> ResolvedRangeSetRFC 9110 HTTP byte-range parser, resolver, serializer, response planner and audit toolkit for MoonBit.