Skip to content

Commit 9c9b79a

Browse files
docs(api): document download params honored by HEAD
1 parent 38ea652 commit 9c9b79a

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

openapi/Swarm.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,17 @@ paths:
255255
$ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress"
256256
required: true
257257
description: Swarm address of chunk
258+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmCache"
259+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyStrategyParameter"
260+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyFallbackModeParameter"
261+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyLevelParameter"
262+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmChunkRetrievalTimeoutParameter"
258263
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
259264
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
260265
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
261266
responses:
262267
"200":
263-
description: The chunk exists.
268+
description: Headers for the content at the reference.
264269
headers:
265270
Content-Type:
266271
description: The MIME type of the resource (e.g., application/octet-stream).
@@ -489,12 +494,17 @@ paths:
489494
$ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress"
490495
required: true
491496
description: Swarm address of chunk
497+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmCache"
498+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyStrategyParameter"
499+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyFallbackModeParameter"
500+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyLevelParameter"
501+
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmChunkRetrievalTimeoutParameter"
492502
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
493503
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
494504
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
495505
responses:
496506
"200":
497-
description: Chunk exists
507+
description: Headers for the content at the reference.
498508
headers:
499509
Content-Type:
500510
description: The MIME type of the resource.

pkg/api/bytes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ func TestBytesHeadErrorsMatchGet(t *testing.T) {
507507
ref string
508508
want int
509509
}{
510-
{"unresolvable address", "abcd", http.StatusInternalServerError},
510+
{"short address", "abcd", http.StatusInternalServerError},
511511
{"unknown address", "0000000000000000000000000000000000000000000000000000000000000001", http.StatusNotFound},
512-
{"invalid address", "zzzz", http.StatusBadRequest},
512+
{"non-hex address", "zzzz", http.StatusBadRequest},
513513
}
514514

515515
for _, tt := range tests {

pkg/api/bzz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ func (s *Service) downloadHandler(logger log.Logger, w http.ResponseWriter, r *h
794794
w.Header().Add(AccessControlExposeHeaders, ContentDispositionHeader)
795795

796796
if headersOnly {
797-
// http.ServeContent sets this on the GET path, but is not reached here.
797+
// http.ServeContent would set this, but the GET path is not reached here.
798798
// "bytes" is the range unit, not the endpoint.
799799
w.Header().Set(AcceptRangesHeader, "bytes")
800800
w.Header().Add(AccessControlExposeHeaders, AcceptRangesHeader)

pkg/api/bzz_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ func TestBzzFiles(t *testing.T) {
597597
jsonhttptest.WithRequestBody(bytes.NewReader(simpleData)),
598598
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"),
599599
jsonhttptest.WithExpectedContentLength(21),
600+
jsonhttptest.WithExpectedResponseHeader(api.AcceptRangesHeader, "bytes"),
600601
)
601602
})
602603
})

0 commit comments

Comments
 (0)