Spaces:
Running
Running
|
Download CONTRACT.md from WideChaos/http-range-desk: direct link, hf CLI and curl.
- Browser
- Download file 8.96 kB
-
https://huggingface.co/spaces/WideChaos/http-range-desk/resolve/main/CONTRACT.md
- Command line
-
hf download hf://spaces/WideChaos/http-range-desk/CONTRACT.md
-
curl -L -o CONTRACT.md https://huggingface.co/spaces/WideChaos/http-range-desk/resolve/main/CONTRACT.md
8.96 kB
| # HTTP Range Desk contract v1 | |
| Renchao Wu · work:http-range-desk:v1 · original Apache-2.0 implementation, fixtures and sample bytes. Freeze before production implementation. RFC9110 defines HTTP semantics; this declared bounded profile chooses optional server policies and does not certify a real server, safety, download correctness, HTTP conformance, representation existence or validator authenticity. No model fitting or training. | |
| ## Input | |
| Exact JSON keys: method, base_status, resource, range, if_range. method string GET or HEAD only. base_status numeric200/304/412 is caller-asserted outcome after any other preconditions; this tool does not parse If-Match/If-None-Match/If-Modified-Since or do authentication/content negotiation. resource exact keys length,etag,last_modified,date_is_strong. length canonical nonnegative decimalstring0..9223372036854775807; noJSONnumber/coercion/sign/leadingzeros. etag null or syntactically valid quotedentitytag with optional case-sensitive W/weak prefix; opaquechars %x21/%x23-7E/%x80-FF, max1024UTF16units, no escapes interpreted/backslash ordinarycharacter. last_modified null or exact canonical IMF-fixdate29characters with realGregorian date/weekday, year1601..9999, seconds00..59, GMT; noleapsecond underthisprofile. date_is_strong bool is caller assertion, not inferred strength; truewithnull lastmodified rejected. Dates in older HTTP forms are outside this inputprofile, not invalidHTTP. range null or headerstring<=8192UTF16units; if_range null orstring<=1024UTF16units. CR/LF/NUL in headerfields typedinputrejection, not normal server outcome. WholeJSON max65536UTF16units UI/APItext/65536bytesCLI independently specified. Emptyheader is presentempty not null. | |
| Optional Uint8Array payload from actual local file capped1048576bytes; nofetch/upload/execution. Its observedlength must exactlymatch suppliedresource.length before emitting result, even ifRangeignored. Withoutpayload resource length is onlyassertedmetadata, noactualfileorhashinvented. Exportpayload fullbytesnotrequired; boundedhexpreviewfirst32bytes perselectedinterval +complete sliceSHA256+size. Emptyactualfile valid; shaemptyactual. Fileidentity fileSHA notpath/name, nofilemtime treatedasHTTPmodtimeorETag. Binaryslices neednotvalidUTF8; nevertreatoffsetsascharacters or decodebeforehash. | |
| ## Order and Range parser | |
| Preserveexactrequest, SHA256 ofUTF8(JSON.stringify(snapshot)) labeledrequestsnapshotdigest notrawJSONbytehash; ifactualpayload available retainfullbytesSHA. Noemptyfield autofill. Decision order: base_status304/412 first=>range not evaluated; HEAD=>Rangeignored/200; range null=>full200/noRange; otherwise parseRange. If-Range withoutRangeignored perRFC13.1.5. InvalidIfRange doesnotturnunsatisfiableRange into416ifconditionfalse. If validRange supported, evaluateIfRange condition before applyingRange; false=>full200. Parsing can still exposeheaderdiagnostic, butnotemit416whenIfRangefails. IfRangepresentHTTPdateoutsideIMF profile=>outside-profile report, no invented response prediction. | |
| Rangeunit grammar token, case-insensitive bytes support; other syntacticallyvalidunit=>unsupported-unit/ignored200, not corrupt. malformedunit/equals=>malformed/ignored200 chosenpolicy. Afterexactsingleequals sign, listmembers separatedcomma; RFC#list OWS SP/HTAB aroundmembers; accept and ignore emptylistmembers up to64empty elements, require>=1nonempty; preservealloriginalmemberordinals includingempty tokens andignored status. cap64nonemptyrange-specs or >64empty=>outside-profile withresponsepredictionnull, notHTTPmalformed. Eachnumericcomponentmax256decimaldigits (leadingzerosaccepted), overlimit=>outside-profile; entireheader8192cap handledtypedinput. NointernalOWSaroundhyphen orwithinrange; membergrammar first-last/first-/-suffix; digitsASCIIonly. Last<first invalidentirerangespec=>malformed/ignored200, notpartiallyapplyvalidsiblings. Syntaxparser mustpreserve per-member raw/ordinal/type/numericstringscanonicalized and interval/validity/satisfiability. Any malformedmember invalidateswholerange; no fabricatedselectedpartial aftermalformed sibling. | |
| First/last positionsareinclusivezero-basedoctets; deriveexclusiveend/lengthseparately. Forn>0: first<n satisfiable, end=min(explicitlast,n-1) or n-1; first>=n unsatisfiable. SuffixN>0 satisfiable, start=max(0,n-N),end=n-1. Suffix0 unsatisfiable. Forn0: nonzerosuffix semanticallysatisfiablebutempty (start0,exclusive_end0,lastnull,length0), asRFC14.1.2; normalfirst rangesunsatisfiable. No negativebytes orfictionallast=-1. | |
| If syntacticallyvalidrange andconditiontrue butn0, chosenemptyrepresentationpolicyignoreRange/full200 underRFC14.2 regardlessofsemanticpresenceofsuffix; retaindiagnostics/counts. Otherwise n>0and>=1satisfiable range=>planned206; retainallvalidsiblingunsatisfiables asdiagnostics, selectonlysatisfiableintervals inrequestorder. none=>planned416 andContent-Range bytes */n. malformed=>chosenignore200; unsupported=>ignore200. Serversmaylegallyignore/reject/coalesce differently; responsecode is thisprofile'splan only. Outsideprofile predictionnull, notcertifiedserverfailure. | |
| ## If-Range | |
| null=>not-present/allow. Entitytag syntaxrecognized fromoptionalW/quotedtag. Matchingrequiresbothstrongandbyteexactopaquevalue; weakrequest/current nevermatches. Invalidentitytagfield=>invalid-validator/nonmatch=>full200 (chosenignoreRange policy), retain. IMFdate canonical valid=>matchonly ifresource.date_is_strongtrue, last_modifiedknown, and exacttimestamp equality includingseconds; futuredate doesnotmatch (unlike<=conditional). Callerasserteddate strength notverified. Otherrawfield notvalidtag/IMF=>outside-profile if resembles obsoletevaliddate (RFC850/asctime) or leap-secondIMF, otherwise invalid-validator/nonmatch; do not silentlyparse Date.parse permissiveformats. Range null/HEAD/base304412 do notparseIfRangeor pretend malformedfields affectedresponse. Originalformat/raw preserved. | |
| ## Report and counting | |
| Report schema http-range-desk-report-v1 includesexactrequest/provenance/profile/decisiontrace/order/responseplan, parserstatus plusallmembers/ordinal/raw/numericstrings/syntaxstatus/satisfiability/exclusiveintervals, IfRangeconditiondetail andassertionlabel. Parsedcounts preserve originalmembers, empties, nonemptyvalid/invalid/unsupported profiles; do notclaimfullparsingifcapstops. Forwholemalformedrange selectedintervals empty evenwhenearliermembervalid. No partialselectedresponse masqueradingwholevalidity. | |
| A206singleinterval getsContent-Range bytes first-last/n. Multipartplanhasper-partContentRange andtopContentRangenull; do notinventboundary/body/wireContentLength. Chosenpolicykeep every satisfiableinterval inrequestorderincludingduplicate/overlap/adjacency. selected_payload_bytes sumswithrepetitions; unique_payload_bytes lengthofsortedcoalescedunion; overlap_payload_bytes=sum−union; showboth exactdecimalstrings. Unionmergesoverlap/adjacency onlyfordiagnosticnotrequestrewrite. Single/multipartbodywirelengthunknown becauseboundaries/partheadersnotconstructed. full200 GET useswholeintervalonlyifn>0, 0filezero intervals/0length; HEAD/304/412/416/outsideprofile noselecteddata intervals. HEADrepresentationlength knownbutbody0;304/412/416 no claimerror-bodylengthknown, no contentlengthinvented. noRangeGETstatus200fullbodylenknown. Forpayload samples computeactualwholeSHA andselectedslices/hash/first32hex, boundedby1MiB, nointegerNumberconversionuntilobservedboundverified. DownloadJSONcompleteoriginalmembers/selectedintervals/union/slices, filter/pagingdoesnottruncate. CSVdeclaredselectedintervalsubset andperpartinclusive/exclusive/length/hashfields; unsupportedprediction outsideprofile exportedfullJSONdiagnostic, no inventedstatusnumber. | |
| ## Product/verification | |
| Threeoriginalbinarysamples including0byte/UTF8emojiwithCRLFandNUL/allbytevalues; noemployer/private/thirdpartyfiles. BrowserJSONandactualFileChooser locallyregisterpayloadlengthbyexplicitaction, staleoverlapresourcefilemismatchrejected; Clearclearsallfile/raw/report/export, failedparsecannotleaveoldresults. Monotonicintent/resourcegeneration preventsdelayedexamples/fileloads/newinput/clear/restore fromoverwritingnewintent. Simpleinitiallocalfixtureload late7cases success503 throughrealfilegatedHTTP; no untrusted remoteURL. JSONcomplete andCSVsubset downloadandreadbacknative, allbadtyped/headercaps/huge2^63/MAXoffset/UTF8byte slices/zerosuffix/emptyfile/nonzero suffix/futuredateexactnegative/weakETag/304precedence/HEAD/duplicates/emptylist/malformed sibling preserved. Actual3753901280/46control/3focus/scroll/console andhumanizer. Independentstdlibcharacterparser+smallenumeratedbyteoracle, pre-frozenliteralexpectedbank plusfreshcase generation/allentirereports/CLI/subprocess/exacthash +independenttotaloutputnewprimary/spec/math/native acceptance before34→35. OriginalRFCcontentnotcopied; no universalRFCbadge/HTTPservercertificate/realdownload/publichost/adoptionclaim. No release undercurrenthold. | |