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

http.ServeContent Internal Server Error with ObjectOpenFile #78

Closed
hexadecy opened this issue Oct 31, 2016 · 2 comments
Closed

http.ServeContent Internal Server Error with ObjectOpenFile #78

hexadecy opened this issue Oct 31, 2016 · 2 comments

Comments

@hexadecy
Copy link
Contributor

hexadecy commented Oct 31, 2016

When we try to serve a resumable object (like an audio file), ObjectOpenFile cannot Seek directly to the end.
Because in http.ServeContent size is determined that way:
size, err := content.Seek(0, io.SeekEnd)

We just add one return as a quickfix in swift.go

func (file *ObjectOpenFile) Seek(offset int64, whence int) (newPos int64, err error) {
	switch whence {
	case 0: // relative to start
		newPos = offset
	case 1: // relative to current
		newPos = file.pos + offset
	case 2: // relative to end
		if !file.lengthOk {
			return file.pos, newError(0, "Length of file unknown so can't seek from end")
		}
		newPos = file.length + offset
                **return**
	default:
@ncw
Copy link
Owner

ncw commented Oct 31, 2016

So are you suggesting that we treat the Seek(0, io.SeekEnd) as a special case as it is only used to find the size of the file and avoid doing the re-opening of the file.

Is this for efficiency or does it avoid a bug?

@hexadecy
Copy link
Contributor Author

hexadecy commented Nov 1, 2016

It's to avoid a bug with the http package.

   115  // The content's Seek method must work: ServeContent uses
   116  // a seek to the end of the content to determine its size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants