Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump github.com/valyala/fasthttp from 1.35.0 to 1.37.0 #1882

Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Apr 27, 2022

Bumps github.com/valyala/fasthttp from 1.35.0 to 1.37.0.

Release notes

Sourced from github.com/valyala/fasthttp's releases.

v1.36.0

  • 7cc6f4c Fix DoTimeout Streaming body bug (Erik Dubbelboer)
  • 9a0b4d0 optimize (#1275) (tyltr)
  • e3d2512 optimize (#1272) (tyltr)
  • b40b5a4 Update tlsClientHandshake (#1263) (Mikhail Faraponov)
  • c7576cc Added Windows support and removed some panics (#1264) (Mauro Leggieri)
  • f0e1be5 add nil check of req.body and resp.body on ReleaseBody (#1266) (zzzzwc)
Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 1, 2022

@dependabot rebase

@dependabot dependabot bot force-pushed the dependabot/go_modules/github.com/valyala/fasthttp-1.36.0 branch from 89f6ee9 to c06d35b Compare May 1, 2022
@ReneWerner87
Copy link
Member

ReneWerner87 commented May 1, 2022

we have to check this changes

valyala/fasthttp@c7576cc

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 1, 2022

in new release
https://github.com/valyala/fasthttp/blob/c7576cc10cabfc9c993317a2d3f8355497bea156/fs.go#L98-L125

vs

before
https://github.com/valyala/fasthttp/blob/7a5afddf5b805a022f8e81281c772c11600da2f4/fs.go#L98-L117

and our additional code

fiber/ctx.go

Lines 1349 to 1408 in 2326297

func (c *Ctx) SendFile(file string, compress ...bool) error {
// Save the filename, we will need it in the error message if the file isn't found
filename := file
// https://github.com/valyala/fasthttp/blob/master/fs.go#L81
sendFileOnce.Do(func() {
sendFileFS = &fasthttp.FS{
Root: "/",
GenerateIndexPages: false,
AcceptByteRange: true,
Compress: true,
CompressedFileSuffix: c.app.config.CompressedFileSuffix,
CacheDuration: 10 * time.Second,
IndexNames: []string{"index.html"},
PathNotFound: func(ctx *fasthttp.RequestCtx) {
ctx.Response.SetStatusCode(StatusNotFound)
},
}
sendFileHandler = sendFileFS.NewRequestHandler()
})
// Keep original path for mutable params
c.pathOriginal = utils.CopyString(c.pathOriginal)
// Disable compression
if len(compress) == 0 || !compress[0] {
// https://github.com/valyala/fasthttp/blob/master/fs.go#L46
c.fasthttp.Request.Header.Del(HeaderAcceptEncoding)
}
// https://github.com/valyala/fasthttp/blob/master/fs.go#L85
if len(file) == 0 || file[0] != '/' {
hasTrailingSlash := len(file) > 0 && file[len(file)-1] == '/'
var err error
if file, err = filepath.Abs(file); err != nil {
return err
}
if hasTrailingSlash {
file += "/"
}
}
// Restore the original requested URL
originalURL := utils.CopyString(c.OriginalURL())
defer c.fasthttp.Request.SetRequestURI(originalURL)
// Set new URI for fileHandler
c.fasthttp.Request.SetRequestURI(file)
// Save status code
status := c.fasthttp.Response.StatusCode()
// Serve file
sendFileHandler(c.fasthttp)
// Get the status code which is set by fasthttp
fsStatus := c.fasthttp.Response.StatusCode()
// Set the status code set by the user if it is different from the fasthttp status code and 200
if status != fsStatus && status != StatusOK {
c.Status(status)
}
// Check for error
if status != StatusNotFound && fsStatus == StatusNotFound {
return NewError(StatusNotFound, fmt.Sprintf("sendfile: file %s not found", filename))
}
return nil
}

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 1, 2022

@dependabot rebase

Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.35.0 to 1.36.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](valyala/fasthttp@v1.35.0...v1.36.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/go_modules/github.com/valyala/fasthttp-1.36.0 branch from c06d35b to 72173eb Compare May 1, 2022
@ReneWerner87
Copy link
Member

ReneWerner87 commented May 5, 2022

i tested serval things, but the path is not working for the Send_Immutable test in our windows test machine

code changes in fasthttp:
valyala/fasthttp@c7576cc

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 6, 2022

image
image

problem is this change, whenever the fs handler differs from the normal one and we have to do this because of our wanted customizations for the sendFile method, the path is made the absolute path

Linux:
image

Windows:
image

so it is not possible that our sendFile works with absolute paths

the fact that it works on linux is that the absolute path there is a slash "/" and is stripped in the next lines, so the path is then empty
https://github.com/valyala/fasthttp/blob/c7576cc10cabfc9c993317a2d3f8355497bea156/fs.go#L402-L404

the real problem here is
https://github.com/valyala/fasthttp/blob/c7576cc10cabfc9c993317a2d3f8355497bea156/fs.go#L830-L833
in linux the root is empty, so the filename comes from the request uri, which is created by sendFile using the same principles as in the serverFile method of fasthttp

Linux:
image

Windows:
image
by the absolute path which is added when initializing our custom fs handler
-> the problem arises at the end at this point under windows

and fasthttp is skipping the tests for windows^^
https://github.com/valyala/fasthttp/blob/c7576cc10cabfc9c993317a2d3f8355497bea156/fs_test.go#L1

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 9, 2022

hi @erikdubbelboer, we just have problems with the update to fasthttp 1.36.0

our tests for windows machines have failed due to the above mentioned adjustments

would it be possible to make this part optional
https://github.com/valyala/fasthttp/blob/7cc6f4c513f9e0d3686142e0a1a5aa2f76b3194a/fs.go#L388-L399
so that an empty root can be set even though the generated request handler differs from the default configuration/handler ?

@erikdubbelboer
Copy link

erikdubbelboer commented May 9, 2022

What would you need an empty root for? I don't know your specific case but wouldn't setting it to / work?

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 9, 2022

What would you need an empty root for?

we need the empty root to allow the users to pass an absolute path like your serveFile functionality
https://github.com/valyala/fasthttp/blob/master/fs.go#L130
https://github.com/valyala/fasthttp/blob/master/fs.go#L123

unfortunately we can not use your function, because we want to customize the behavior in case of error and the configuration possibilities.

so fenny had copied it back then and we kept this code in sync as far as possible

only by the line, which looks if the configuration deviates from the standard is a customization no longer possible for us

I don't know your specific case but wouldn't setting it to / work?

slash would work for linux, because the function as described above, then removes the slash and an empty string is present
#1882 (comment)

but on windows, the filePath.isAbs recognizes that it is not an absolute path and changes it directly to the current execution location

best would be, if we can also skip this modification of the configured root

@erikdubbelboer
Copy link

erikdubbelboer commented May 9, 2022

Yeah on Windows you shouldn't pass a / but something like C:/. os.Getwd()[:3] (I know invalid Go) might work best for Windows I think. Wouldn't that fix it?

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 9, 2022

I have already tested
-> unfortunately this does not work completely either

if i mount a fixed drive C:/ (of course relative to the execution), then the user does not have the possibility to mount files from other drives D:/ with absolute paths

with linux this is no problem, because under slash is everything

@erikdubbelboer
Copy link

erikdubbelboer commented May 9, 2022

I see 2 options:

  1. Since the user has to supply the full path you can see if it's C:\ or D:\ and create a new root FS each time they pass a drive you don't have a root FS for.
  2. Make a pull request in fasthttp to add a config option to FS to allow the root to be empty (sorry I don't have time for this myself right now) and I'll merge and release that.

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 9, 2022

Okay thanks for your assessment

so solution number 1 would not be my favorite as it would not be good performance wise

I will create a pull request(solution 2)

ReneWerner87 added a commit to ReneWerner87/fasthttp that referenced this issue May 12, 2022
this is necessary to restore the capabilities before the commit valyala@c7576cc
and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards

gofiber/fiber#1882 (comment)
ReneWerner87 added a commit to ReneWerner87/fasthttp that referenced this issue May 12, 2022
this is necessary to restore the capabilities before the commit valyala@c7576cc
and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards

gofiber/fiber#1882 (comment)
erikdubbelboer added a commit to valyala/fasthttp that referenced this issue May 16, 2022
* Add an option to allow empty root in the fsHandler

this is necessary to restore the capabilities before the commit c7576cc
and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards

gofiber/fiber#1882 (comment)

* Add an option to allow empty root in the fsHandler

this is necessary to restore the capabilities before the commit c7576cc
and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards

gofiber/fiber#1882 (comment)

* Update fs.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Update fs.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github May 17, 2022

A newer version of github.com/valyala/fasthttp exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

@ReneWerner87
Copy link
Member

ReneWerner87 commented May 17, 2022

yeah i will update this PR with the new version
https://github.com/valyala/fasthttp/releases/tag/v1.37.0

@ReneWerner87 ReneWerner87 changed the title Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 Bump github.com/valyala/fasthttp from 1.35.0 to 1.37.0 May 17, 2022
@ReneWerner87 ReneWerner87 merged commit bf0673e into master May 18, 2022
31 checks passed
@dependabot dependabot bot deleted the dependabot/go_modules/github.com/valyala/fasthttp-1.36.0 branch May 18, 2022
trim21 pushed a commit to trim21/fiber that referenced this issue Aug 15, 2022
* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0

Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.35.0 to 1.36.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](valyala/fasthttp@v1.35.0...v1.36.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 gofiber#1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 gofiber#1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 gofiber#1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 gofiber#1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.36.0 gofiber#1882

* Bump github.com/valyala/fasthttp from 1.35.0 to 1.37.0 gofiber#1882

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: wernerr <rene@gofiber.io>
bbenzikry pushed a commit to bbenzikry/fasthttp that referenced this issue Sep 11, 2022
* Add an option to allow empty root in the fsHandler

this is necessary to restore the capabilities before the commit valyala@c7576cc
and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards

gofiber/fiber#1882 (comment)

* Add an option to allow empty root in the fsHandler

this is necessary to restore the capabilities before the commit valyala@c7576cc
and to allow further functionality to be docked from the outside which is not affected by setting the root dir afterwards

gofiber/fiber#1882 (comment)

* Update fs.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Update fs.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants