diff options
author | Steve <nilslice@gmail.com> | 2017-03-07 01:46:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-07 01:46:10 -0800 |
commit | 53f87c86349098c4b91a88f5b0caed484926f07d (patch) | |
tree | 6eb0eded39a1ac0091be1bc3dec64902603e8e4f /system/api/push.go | |
parent | c8bd692a44795f9354acb4583dc35ec3a2604096 (diff) | |
parent | 3607a0094e5bf505d442801d108a9fe6f1ef2e6f (diff) |
Merge pull request #94 from ponzu-cms/ponzu-dev
[core] avoid self-referential server pushes, check Error() equality on recursive push err
Diffstat (limited to 'system/api/push.go')
-rw-r--r-- | system/api/push.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/system/api/push.go b/system/api/push.go index a6402bc..e936ef7 100644 --- a/system/api/push.go +++ b/system/api/push.go @@ -28,9 +28,19 @@ func push(res http.ResponseWriter, req *http.Request, pt func() interface{}, dat return true } + // check that the push is not to its parent URL + if v.String() == (req.URL.Path + "?" + req.URL.RawQuery) { + return true + } + err := pusher.Push(v.String(), nil) - if err != nil && err != http2.ErrRecursivePush { - log.Println("Error during Push of value:", v.String()) + // check for error, "http2: recursive push not allowed" + // and return, supressing a log message + if err != nil && err.Error() == http2.ErrRecursivePush.Error() { + return true + } + if err != nil { + log.Println("Error during Push of value:", v.String(), err) } return true |