Odd Default Content Type? (Resolved/User Error)

(Stephen Couchman) #1

Hey All!

I’m messing around with a pet project and ran into some oddities while testing.

I have an endpoint that uses a size-limited temporary file BodyParser, and I’m testing with Postman.

When I explicitly set the Content Type I get the expected Content Type.
When I don’t set it, instead of None in the contentType Option, I’m getting Some("text/plain")

I had postman send the same request to netcat and got:

POST /project/public/ HTTP/1.1
cache-control: no-cache
Postman-Token: 0b8c2eda-b69d-4ce2-9d2c-9b909b3075f0
User-Agent: PostmanRuntime/7.6.1
Accept: */*
Host: 192.168.1.2:9001
accept-encoding: gzip, deflate
content-length: 0
Connection: keep-alive

So I can see Postman isn’t adding the header without my knowledge, it is correctly absent.
Somewhere between Play and Akka along the way the framework is inventing a “text/plain” content type and lying to me about having it!

It’s definitely not auto-detecting it, as the file I’m testing with is a png.

Body Parser declaration:

def create(public: Boolean): Handler = Action.async(parse.maxLength(FILE_LIMIT, parse.temporaryFile)) { implicit req ⇒
  ???
}

Any suggestions on what might be happening, or how I might detect the missing Content Type would be appreciated. Even the header list is lying to me by the time it gets to my Action!

Thanks!

(Stephen Couchman) #2

Alright, never-mind.

For some reason it seems Postman is indeed sending the nonsense header, it just didn’t show up in my earlier test for some reason I can’t comprehend, repeating the test revealed the header.

Thanks, anyway.