aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/uri.go
diff options
context:
space:
mode:
authorJanoš Guljaš <janos@users.noreply.github.com>2017-12-21 20:47:10 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-12-21 20:47:10 +0800
commit542d51895f54b9f869379cf4ad5549c82e525711 (patch)
tree4f485778b2c28de2d7c4ab446407e7f01eab9b20 /swarm/api/uri.go
parent5258785c81959109138ebeca613f12c277188abc (diff)
downloadgo-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.gz
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.bz2
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.lz
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.xz
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.zst
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.zip
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
Diffstat (limited to 'swarm/api/uri.go')
-rw-r--r--swarm/api/uri.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/swarm/api/uri.go b/swarm/api/uri.go
index af1dc7445..d8aafedf4 100644
--- a/swarm/api/uri.go
+++ b/swarm/api/uri.go
@@ -36,6 +36,8 @@ type URI struct {
// * bzzr - raw swarm content
// * bzzi - immutable URI of an entry in a swarm manifest
// (address is not resolved)
+ // * bzz-hash - hash of swarm content
+ //
Scheme string
// Addr is either a hexadecimal storage key or it an address which
@@ -56,7 +58,7 @@ type URI struct {
// * <scheme>://<addr>
// * <scheme>://<addr>/<path>
//
-// with scheme one of bzz, bzz-raw, bzz-immutable or bzz-list
+// with scheme one of bzz, bzz-raw, bzz-immutable, bzz-list or bzz-hash
// or deprecated ones bzzr and bzzi
func Parse(rawuri string) (*URI, error) {
u, err := url.Parse(rawuri)
@@ -67,7 +69,7 @@ func Parse(rawuri string) (*URI, error) {
// check the scheme is valid
switch uri.Scheme {
- case "bzz", "bzz-raw", "bzz-immutable", "bzz-list", "bzzr", "bzzi":
+ case "bzz", "bzz-raw", "bzz-immutable", "bzz-list", "bzz-hash", "bzzr", "bzzi":
default:
return nil, fmt.Errorf("unknown scheme %q", u.Scheme)
}
@@ -110,6 +112,10 @@ func (u *URI) DeprecatedImmutable() bool {
return u.Scheme == "bzzi"
}
+func (u *URI) Hash() bool {
+ return u.Scheme == "bzz-hash"
+}
+
func (u *URI) String() string {
return u.Scheme + ":/" + u.Addr + "/" + u.Path
}