Content-Type

36 views
Skip to first unread message

Emrys Landivar

unread,
Mar 13, 2013, 10:33:56 AM3/13/13
to chica...@googlegroups.com
even when I explicitly set the content type to "image/png" I get headers:

HTTP/1.1 200 OK
Set-Cookie: _boss_session=2ac716958c5c43c7aa11012c84a06dbdcb944ece; Version=1; Expires=Tue, 19-Mar-2013 16:18:49 GMT; Max-Age=525600; Path=/
Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Wed, 13 Mar 2013 14:18:49 GMT
Content-Type: image/png, text/html
Content-Length: 2381

The "Content-Type: image/png, text/html" is causing my generated images to show as text/html instead of as png's.

What should I do?

Konstantin Nikiforov

unread,
Mar 13, 2013, 10:37:08 AM3/13/13
to chica...@googlegroups.com
Please, show the code from your controller.

В Wed, 13 Mar 2013 07:33:56 -0700 (PDT)
Emrys Landivar <land...@gmail.com> пишет:
signature.asc

Alexander Gounares / Concurix

unread,
Mar 13, 2013, 12:07:21 PM3/13/13
to chica...@googlegroups.com
+1 on showing your code Emrys

We ran into a similar issue when we did not capitalize content-type in our code to set the type.  You'll want the header to look like this in Erlang if it doesn't already...
Headers = [{"Content-Type", ContentType}];

good luck!
alex

Emrys Landivar

unread,
Mar 13, 2013, 12:49:32 PM3/13/13
to chica...@googlegroups.com
# I am using elixir.

defmodule Checkeriner.QrgenController do
  use Boss.WebController

  get :qrencode, [code] do
    acode = :qrcode.encode(code)
    bcode = :qrcode_demo.simple_png_encode(acode)
    {:output, [bcode], [{"Content-Type", "image/png"}]} 

  end

end

#the output from the html looks like this:

‰PNG IHDRèè jË?/ )IDATxœíš1²+9 ÿý/½›8x‰g `ˆvw¬"@NG.ÿû ` ÿÚ v@\ âÂH F‚¸0 Ä…‘ .Œ qa$ˆ #A\ âÂH F‚¸0 Ä…‘ .Œ qa$ˆ #A\ âÂH F‚¸0 Ä…‘ .Œ qa$ˆ #A\ âÂH F‚¸0 Ä…‘ .Œ$.î¿!¸ör½ÿµ{Êwˆ Áµ—ëý¯ÝS¾C<` ®½\ï ížò â Cpíåzÿk÷”ï ‚k/×û_»§|‡xÀ \{¹ÞÿÚ=å;Ä †àÚËõþ×î)ß! 0 ×^®÷¿vOù ñ€Òb­>é ÿk÷|› ø±C¯«yM«¿J« âšû¬«yM«¿J« âšû¬«yM«¿J« âšû¬«yM«¿J« âšû¬«yM«¿J« âšû¬«yM«¿J« âšû¬«yM«¿J«Ïqâ>ýà»óÓ{¹æ¸Þ«¤ï ‚¸›‡nÍq½WIßA q7 Ýšãz¯’¾ƒ ân º5Çõ^%} ÄÝ. ÷S‡.õWsÓ}\ î§ ]ê¯æ¦û¸@ÜO ºÔ_ÍM÷q ¸Ÿ:t©¿š›îã q?uèR 57ÝÇ â~êÐ¥þjnº ÄýÔ¡KýÕÜt lj{ZŸéý¿µ â"îÈ>ˆ‹¸#û .âŽìƒ¸ˆ;² â"îÈ>ˆ‹¸#û .âŽìsÜ ï-Ôþ§½? uCö@Ü jÿÓޟƺ!{ î µÿiïOcÝ = ÷…Úÿ´÷§±nÈ ˆûBí ÚûÓX7d Ä}¡ö?íýi¬ ² â¾PûŸöþ4Ö Ù q_¨ýO{ ë†ìQûáú[i}È_ƒƒšAÜÏÀAÍ îgà f ÷3pP3ˆû 8¨ Äý Ô â~ j q?Ø?’«sÞ½wÍqå¶zN qÍB¨¹­žÓA\³ jn«çt ×,„šÛê9 Ä5 ¡æ¶zN qÍB¨¹­žÓA\³ jn«çt ×,„šÛê9 1‹¥?Œk~KÄÖ}Ò¹oû¤ \´>ŒkŽ:?ý¾µ—­O:ÀEëøæ¨óÓï[{Ùú¤ \´>ŒkŽ:?ý¾µ—­O:ÀEëøæ¨óÓï[{Ùú¤ \´>ŒkŽ:?ý¾µ—­O:ÀEëøæ¨óÓï[{Ùú¤ \´>ŒkŽ:?ý¾µ—­O<À´°:Ç•›îÓÊuõTß»@Ü›ÜtŸV®«§úÞ âÞä¦û´r]=Õ÷. ÷&7ݧ•ëꩾw ¸7¹é>­\WOõ½ ĽÉM÷iåºzªï] îMnºO+×ÕS}ï qorÓ}Z¹®žê{ Çý‘¼u¸õOø™þ-Ò÷q ¸7sZý[¤ïã qoæ´ú·HßÇ âÞÌiõo‘¾ Ľ™Óêß"} ˆ{3§Õ¿Eú>. ÷fN« ‹ô}\ îÍœVÿ éû¸¨ý‘<}hW®:'ýþ´þê ˆ»9¿õþ´þê ˆ»9¿õþ´þê ˆ»9¿õþ´þê ˆ»9¿õþ´þê ˆ»9¿õþ´þê ˆ»9¿õþ´þê ˆ»9¿õþ´þê 5q§ðL›ý éšïêïêã qoh}H×|W W ˆ{CëCºæ»ú»ú¸@Ü Z Ò5ßÕßÕÇ âÞÐú ®ù®þ®>. ÷†Ö‡tÍwõwõq ¸7´>¤k¾«¿« Ľ¡õ!]ó]ý]}\ÔþH~ ®½\whåºz¦AÜ ®½\whåºz¦AÜ ®½\whåºz¦AÜ ®½\whåºz¦AÜ ®½\whåºz¦AÜ ®½\whåºz¦AÜ ®½\whåºz¦AÜ ®½\whåºz¦©‰›Îuõ9í ·îÙÊ}Û' pÚÂbŸu5¯iõŸžû¶O<à´…Å>ëj^Óê?=÷mŸxÀi ‹}ÖÕ¼¦Õ zîÛ>ñ€Ó û¬«yM«ÿôÜ·}â §-,öYWóšVÿé¹oûÄ N[Xì³®æ5­þÓsßö‰ œ¶°Øg]ÍkZý§ç¾í ~*ÈîüoÝ×Õ3=GÎ ˆ‹=ý€»ó¿u_WÏô 97 .öô îÎÿÖ}]=ÓsäÜx€¸ØÓ ¸;ÿ[÷uõLÏ‘sã âbO?àîüoÝ×Õ3=GÎ ˆ‹=ý€»ó¿u_WÏô 97 .öô îÎÿÖ}]=ÓsäÜx€¸ØÓ ¸;ÿ[÷uõLÏ‘sã âbO?àî|WŸ§÷â k ®¹ÏÓ{q‡5 ×Üç齸à ˆkîóô^Üa Ä5÷yz/î° âšû<½ wX qÍ}žÞ‹;¬ ¸æ>OïÅ Ö@ÜO ú°;¤{ª¹rÏx€é *®>.N»Cº§š+÷Œ ˜ ¡âêãâ´;¤{ª¹rÏx€é *®>.N»Cº§š+÷Œ ˜ ¡âêãâ´;¤{ª¹rÏx€é *®>.N»Cº§š+÷Œ ˜ ¡âêãâ´;¤{ª¹rÏx€é *®>.N»Cº§š+÷Œ ” K÷YWg ô^®Ü ˆk ÅEz/Wn Ä5‹â"½—+· âšEq‘ÞË•Û qÍ¢¸HïåÊm ¸fQ\¤÷rå¶@\³(.Ò{¹r[ ®Y é½\¹-j➆Úßõ¾•»~™kÔ½\ î µ¿ë}+wý2ר{¹@Ü j ×ûVîúe®Q÷r ¸/Ôþ®÷­ÜõË\£îå q_¨ý]ï[¹ë—¹FÝË â¾Pû»Þ·r×/s º— Ä}¡öw½oå®_æ u/ ˆûBíïzßÊ]¿Ì5ê^.Æüà ð Ä…‘ .Œ qa$ˆ #A\ âÂH F‚¸0 Ä…‘ .Œ qa$ˆ #A\ âÂH F‚¸0 Ä…‘ .Œ qa$ˆ #A\ âÂH F‚¸0 Ä…‘ .Œ qa$ˆ #A\ âÂH Fò?7 yá ú-IEND®B`‚

Emrys Landivar

unread,
Mar 13, 2013, 2:32:36 PM3/13/13
to chica...@googlegroups.com
Ok, I fixed the problem, but I had to patch chicago boss
:-(

Line 615 in boss_web_controller.erl was changed from:
{200, merge_headers(Headers, [{"Content-Type", "text/html"}]), Payload};

to:
{200, merge_headers([{"Content-Type", "text/html"}], Headers), Payload};

This bugfix makes the custom Content-Type the last one (which is the
one that matters).

Should I submit a formal pull request?

Evan Miller

unread,
Mar 13, 2013, 2:56:12 PM3/13/13
to ChicagoBoss
I think what's happening is that double-quoted Elixir strings are
binaries, whereas double-quoted Erlang strings are lists, so your
"Content-Type" is not equal to boss_web_controller's "Content-Type"
and they're not being merged properly.

Try this patch:

https://github.com/evanmiller/ChicagoBoss/commit/1c2f6206e6da3a5ec7c2ff05b33669e5379a02ee

Evan
> --
> You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Evan Miller
http://www.evanmiller.org/
Reply all
Reply to author
Forward
0 new messages