From 542d51895f54b9f869379cf4ad5549c82e525711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jano=C5=A1=20Gulja=C5=A1?= Date: Thu, 21 Dec 2017 13:47:10 +0100 Subject: swarm/api: url scheme bzz-hash to get hashes of swarm content (#15238) (#15715) * swarm/api: url scheme bzz-hash to get hashes of swarm content (#15238) Update URI to support bzz-hash scheme and handle such HTTP requests by responding with hash of the content as a text/plain response. * swarm/api: return hash of the content for bzz-hash:// requests * swarm/api: revert "return hash of the content for bzz-hash:// requests" Return hashes of the content that would be returned by bzz-raw request. * swarm/api/http: handle error in TestBzzGetPath * swarm/api: remove extra blank line in comment --- swarm/api/uri_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'swarm/api/uri_test.go') diff --git a/swarm/api/uri_test.go b/swarm/api/uri_test.go index babb2834e..137b4505d 100644 --- a/swarm/api/uri_test.go +++ b/swarm/api/uri_test.go @@ -29,6 +29,7 @@ func TestParseURI(t *testing.T) { expectRaw bool expectImmutable bool expectList bool + expectHash bool expectDeprecatedRaw bool expectDeprecatedImmutable bool } @@ -98,6 +99,16 @@ func TestParseURI(t *testing.T) { uri: "bzz://abc123/path/to/entry", expectURI: &URI{Scheme: "bzz", Addr: "abc123", Path: "path/to/entry"}, }, + { + uri: "bzz-hash:", + expectURI: &URI{Scheme: "bzz-hash"}, + expectHash: true, + }, + { + uri: "bzz-hash:/", + expectURI: &URI{Scheme: "bzz-hash"}, + expectHash: true, + }, { uri: "bzz-list:", expectURI: &URI{Scheme: "bzz-list"}, @@ -152,6 +163,9 @@ func TestParseURI(t *testing.T) { if actual.List() != x.expectList { t.Fatalf("expected %s list to be %t, got %t", x.uri, x.expectList, actual.List()) } + if actual.Hash() != x.expectHash { + t.Fatalf("expected %s hash to be %t, got %t", x.uri, x.expectHash, actual.Hash()) + } if actual.DeprecatedRaw() != x.expectDeprecatedRaw { t.Fatalf("expected %s deprecated raw to be %t, got %t", x.uri, x.expectDeprecatedRaw, actual.DeprecatedRaw()) } -- cgit v1.2.3