Fork me on GitHub
#yada
<
2018-12-06
>
borkdude13:12:01

when I have these options:

:media-type #{"text/plain"
                   #_"application/octet-stream"}
I get the response as a viewable text file in the browser. But when I add "application/octet-stream", it won’t show in the browser but becomes a download, although the request/response headers seem identical. Any idea?

borkdude13:12:35

Download:

Connection: Keep-Alive
Content-Length: 2053470
Content-Type: text/plain
Date: Thu, 06 Dec 2018 13:17:18 GMT
Server: Aleph/0.4.4
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

Viewable as plain text:

Connection: Keep-Alive
Content-Length: 2053470
Content-Type: text/plain
Date: Thu, 06 Dec 2018 13:19:14 GMT
Server: Aleph/0.4.4
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

malcolmsparks13:12:21

That's odd. Try adding a q value

malcolmsparks13:12:49

Could you raise an issue? Worth capturing this.

borkdude13:12:25

:media-type #{"text/plain; q=1"
                   "application/octet-stream; q=0.9"}
seems to work OK

malcolmsparks13:12:25

Are you somehow manually setting Content-Type in the response in your code?

borkdude13:12:44

nope, I return a string as the response

borkdude13:12:48

{:swagger/tags ["articles"]
    :produces
    {:media-type #{"text/plain; q=1"
                   "application/octet-stream; q=0.9"}}
    :methods
    {:get
     {:swagger/summary "Export search results to nbib format"
      :parameters {:query {(s/optional-key :limit) s/Int
                           :blunt String
                           (s/optional-key :format) String}}
      :response
      (fn [ctx]
        ... <- string)}}}