You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When go http server cannot recognize content type it tries to read 512 bytes from the resource. You can see it here.
It's a dirty cheat.
First of all the resource can be unavailable for further reading.
Secondly if you try to implement your own WebDAV server you need to append or cut part of bytes to fill the buffer right.
Due to code will smell like the following.
iflen(f.data) <len(p) {
// min buffer for http server is 512, so if file is less than one we need to add empty bytesmissed:=len(p) -len(f.data)
copy(p, append(make([]byte, missed)))
} else {
copy(p, f.data[:len(p)])
}
Any ideas how to prevent this behaviour?
BTW go hasn't recognized .md and .py files as text/plain type.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
frontend/libgo/go/net/http: Dirty content type check
net/http: problematic content type check
Jun 24, 2022
You don't have to supply 512 bytes to satisfy the content type check. You can simply return the bytes available, and then io.EOF.
Go will read the MIME extensions that are defined on your system. You didn't mention what kind of system you are using. Your program can define additional MIME extensions by calling https://pkg.go.dev/mime#AddExtensionType.
I don't see a bug here, and we don't use the issue tracker for questions or discussion, so closing. If you have further questions, please see https://go.dev/wiki/Questions.
When go http server cannot recognize content type it tries to read 512 bytes from the resource. You can see it here.
It's a dirty cheat.
First of all the resource can be unavailable for further reading.
Secondly if you try to implement your own WebDAV server you need to append or cut part of bytes to fill the buffer right.
Due to code will smell like the following.
Any ideas how to prevent this behaviour?
BTW go hasn't recognized
.md
and.py
files astext/plain
type.The text was updated successfully, but these errors were encountered: