Skip to content

net/http: problematic content type check #53545

Closed as not planned
Closed as not planned
@xepozz

Description

@xepozz

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.

if len(f.data) < len(p) {
	// min buffer for http server is 512, so if file is less than one we need to add empty bytes
	missed := 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions