From 2ec3fd7d00cea5e4bd9079bb95d086c1d390c719 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 3 Jan 2017 22:41:56 +0100 Subject: [PATCH] swarm: Added public access method Parse alias to parse --- swarm/api/api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/swarm/api/api.go b/swarm/api/api.go index 673cff350a..63de449b08 100644 --- a/swarm/api/api.go +++ b/swarm/api/api.go @@ -22,6 +22,7 @@ import ( "regexp" "strings" "sync" + "net/http" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/logger" @@ -71,6 +72,7 @@ type ErrResolve error // DNS Resolver func (self *Api) Resolve(hostPort string, nameresolver bool) (storage.Key, error) { + glog.V(logger.Warn).Infof("Resolving : %v", hostPort) if hashMatcher.MatchString(hostPort) || self.dns == nil { glog.V(logger.Detail).Infof("host is a contentHash: '%v'", hostPort) return storage.Key(common.Hex2Bytes(hostPort)), nil @@ -87,6 +89,10 @@ func (self *Api) Resolve(hostPort string, nameresolver bool) (storage.Key, error return contentHash[:], err } +func Parse(url string) (hostPost, path string) { + return parse(url) +} + func parse(uri string) (hostPort, path string) { parts := slashes.Split(uri, 3) var i int @@ -150,7 +156,9 @@ func (self *Api) Get(uri string, nameresolver bool) (reader storage.LazySectionR } glog.V(logger.Detail).Infof("getEntry(%s)", path) + entry, _ := trie.getEntry(path) + if entry != nil { key = common.Hex2Bytes(entry.Hash) status = entry.Status @@ -158,6 +166,7 @@ func (self *Api) Get(uri string, nameresolver bool) (reader storage.LazySectionR glog.V(logger.Detail).Infof("content lookup key: '%v' (%v)", key, mimeType) reader = self.dpa.Retrieve(key) } else { + status = http.StatusNotFound err = fmt.Errorf("manifest entry for '%s' not found", path) glog.V(logger.Warn).Infof("%v", err) }