Skip to content

Commit

Permalink
fix #921
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Mar 8, 2018
1 parent 78cd8e5 commit dc589d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestConfigurationStatic(t *testing.T) {

afterNew = *app.config

if app.config.DisableBodyConsumptionOnUnmarshal == false {
if !app.config.DisableBodyConsumptionOnUnmarshal {
t.Fatalf("Passing a Configuration field as Option fails, expected DisableBodyConsumptionOnUnmarshal to be true but was false")
}

Expand Down
8 changes: 8 additions & 0 deletions core/router/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ func (h *routerHandler) HandleRequest(ctx context.Context) {
r.URL.Path = path
url := r.URL.String()

// Fixes https://github.com/kataras/iris/issues/921
// This is caused for security reasons, imagine a payment shop,
// you can't just permantly redirect a POST request, so just 307 (RFC 7231, 6.4.7).
if method == http.MethodPost || method == http.MethodPut {
ctx.Redirect(url, http.StatusTemporaryRedirect)
return
}

ctx.Redirect(url, http.StatusMovedPermanently)

// RFC2616 recommends that a short note "SHOULD" be included in the
Expand Down
7 changes: 3 additions & 4 deletions sessions/sessiondb/redis/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ func (r *Service) GetBytes(key string) ([]byte, error) {
func (r *Service) Delete(key string) error {
c := r.pool.Get()
defer c.Close()
if _, err := c.Do("DEL", r.Config.Prefix+key); err != nil {
return err
}
return nil

_, err := c.Do("DEL", r.Config.Prefix+key)
return err
}

func dial(network string, addr string, pass string) (redis.Conn, error) {
Expand Down
2 changes: 1 addition & 1 deletion view/handlebars.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (s *HandlebarsEngine) loadDirectory() error {
// instead of the html/template engine which works like {{ render "myfile.html"}} and accepts the parent binding, with handlebars we can't do that because of lack of runtime helpers (dublicate error)

var templateErr error
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
filepath.Walk(dir, func(path string, info os.FileInfo, _ error) error {
if info == nil || info.IsDir() {
return nil
}
Expand Down

0 comments on commit dc589d9

Please sign in to comment.