Skip to content

Commit

Permalink
Revert logic change
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby committed Mar 4, 2024
1 parent d7fce2d commit c9a033c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions middleware/favicon/favicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,18 @@ func New(config ...Config) fiber.Handler {
return c.Next()
}

// Only allow GET, HEAD, and OPTIONS requests
if c.Method() != fiber.MethodGet && c.Method() != fiber.MethodHead && c.Method() != fiber.MethodOptions {
c.Status(fiber.StatusMethodNotAllowed)
// Only allow GET, HEAD and OPTIONS requests
if c.Method() != fiber.MethodGet && c.Method() != fiber.MethodHead {
if c.Method() != fiber.MethodOptions {
c.Status(fiber.StatusMethodNotAllowed)
} else {
c.Status(fiber.StatusOK)
}
c.Set(fiber.HeaderAllow, hAllow)
c.Set(fiber.HeaderContentLength, hZero)
return nil
}

if c.Method() == fiber.MethodOptions {
return c.SendStatus(fiber.StatusOK)
}

// Serve cached favicon
if iconLen > 0 {
c.Set(fiber.HeaderContentLength, iconLenHeader)
Expand Down
2 changes: 1 addition & 1 deletion middleware/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func Test_Proxy_DoDeadline_PastDeadline(t *testing.T) {

app := fiber.New()
app.Get("/test", func(c fiber.Ctx) error {
return DoDeadline(c, "http://"+addr, time.Now().Add(time.Second))
return DoDeadline(c, "http://"+addr, time.Now().Add(2*time.Second))
})

_, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil), int((1*time.Second)/time.Millisecond))
Expand Down

0 comments on commit c9a033c

Please sign in to comment.