Created
May 16, 2011 17:05
-
-
Save radixhound/974854 to your computer and use it in GitHub Desktop.
posting multipart form to goliath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://localhost:9000/photos -X POST -F "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[30511:INFO] 2011-05-16 09:59:26 :: Starting server on 0.0.0.0:9000 in development mode. Watch out for stones. | |
[30511:INFO] 2011-05-16 09:59:28 :: received headers: {"User-Agent"=>"curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3", "Host"=>"houseofgold.i:9000", "Accept"=>"*/*", "Authorization"=>"FTAuth dHiPSjyo2s73CauGUykH", "Content-Length"=>"22474", "Expect"=>"100-continue", "Content-Type"=>"multipart/form-data; boundary=----------------------------c80643c7bdcc"} | |
[30511:INFO] 2011-05-16 09:59:30 :: DATA SIZE: 146 | |
[30511:INFO] 2011-05-16 09:59:30 :: body data:------------------------------c80643c7bdcc | |
Content-Disposition: form-data; name="photo"; filename="yummyfood01.jpg" | |
Content-Type: image/jpeg | |
[30511:INFO] 2011-05-16 09:59:30 :: DATA SIZE: 16384 | |
[30511:INFO] 2011-05-16 09:59:30 :: received something bigger than 9kb | |
[30511:INFO] 2011-05-16 09:59:30 :: DATA SIZE: 5944 | |
[30511:INFO] 2011-05-16 09:59:30 :: body data:a??+?2???7*߾????So? | |
?????L??u??j????G?Olm | |
?^?}ed??tD?????4??a+ ?c?Y?`"???o'Z?M??H,m?V-???s :?54o??v?c?I?k?M?&Oq??|f?? | |
q?????Q??AY?YP?a???-?Ř ??Q??)/;?x? ?!?nA?47?????\???3O8??<?? | |
?e?3?N#$i?r)??????&??$??/??MB??#?%?:?oeWM0?qm???i6oV?Ψf?i??܂u?_ | |
X?MLaE?????i{_?Mg{?t_?c??C?s ٝ???w??n?0????zg?N??j???o????r?y | |
(?C?????}?????g?k?ۏ????R????a?u???jǨ$??5?{????"?j? | |
?f?F?b?????ʫ?A?N?z???????}he1? k?x?@????F??I?7?Iu?ߦ;?ץx?*??θְ????$F???kk??-??v? | |
9 *??u?C?n? ??u`R9a????)?ͩ?????_???X?1?+L?I2??!U????&?D?d??ڸ?U?5ۏZ???W<e??Lj?!D????)1"K?]wҝ??B?;[j?B?* | |
?W,}7B??Dmk??^?x @.t?q?h??;0t????m??~?)a??v?%w*:?c?'B?zQxJ??l(?GUՅ-β??"?u?nÏk+]Z??cY?)R?\ | |
=|?o???+?(s???w?U??R??ޤ??8??x | |
?J?J??$?B?f | |
p??y?#{QQM?N?C?e?91??7??X?&C/=q?P | |
=?j?ϐf???r#???A?Q3ri????[,??A!vK??K?7?Da*??/??9??ٮ?[?v5?????c?????k6c%?k??iU?C.q | |
???Q~Y&??|?z?C?5???Xj???J?)??:??GGK?/S | |
?_#?]????O?l??J$x?sev?7????@???>?/??})??Ck?¬cljE???т??P_???aS???LUA???j?w?M^ڝG??K?z?A?? | |
P?VH?]5bm?&??ٰi??Ha?t??s???f=??ƀ????(/?+??ꇞLn?"D???w%E??????????T?U?4?-c^ll?SY~??7(?.<?o? | |
?1??q?N???d*?氩۲??\F?>??S7*p | |
C?02d͗ T?SA??N? 2I?F??G̿T??????wo??wf??{}?sM??!u???{?d'ɟ?Jr??+???Q???:??-t?]|a??91? ??+?????>7??)e` Ո:?b?QB | |
?A?ϝ9??T??Ӡ?V{?N??[aV? | |
O??uqj?kԬ??c-????].=??m???h????V{???2T???S??F?lkMlM?AVqMҍY*p??S?_??ё?ES???2!1;ڼƣƆ??满?#M????j?ň?68KIa???I?,???,M??i?a???֩?ԠBD?(}8 | |
u??Z?D?Ȭ1? xT?j??j?T???I??r??yWx?^>u?ƺt???|???k?"D????U]?"??[A?;q?9Z?O??g2ݚ???ܑ?^j-:??Z?zD&??"??z | |
v??S?h???Ęm?i???u??Ƥom?C??oM?O?(D?F?? \\??۠?RN??i???#{X~?QYj q??-?- ??^??([%?q???Ȱ?`?ը?)$}?????\;V???ϔ?????3?z?:YFL?d | |
?5?:??5?J???_j?2?????-]????s?u??c?E?I?amu^?S???z_SoeT?p??]g?@???-j?????QA{6??"??u7҄?@:N_?????ԇ`6$[?5?Ic[??mO??ܛ[?O@}?t?ԍϓ?K?tѭ?(?%?,?:??&˙?>L$?f'Ao | |
%?,+?)f?}=?W+!??p?gȓ?v.G?c???P})0Y!?I??)?+???I??q?/?;?x?읽???J???I?ʿ | |
?.????죈2?ň?i???,?M/?MW?B?z?T?T???GE?cbo}@???$??? X?7??C(<x?{?mO?@i??O???m~?K?????Q??F&=?ZW??v?ޅ?s??? ?cԀ<???n.t??̛s?RE0????i;$?2?ٯ???pr?Y??W??E_?^,u??u(%h?&]?Z??7?H?q?۩??j?^a?????cW1? | |
m͵??M??????u#Ƽ}6??P?E???????c?$??"?H????l???k9??%??`4?y??^ ?D???>??w?rJq]?~&?saTr?AYF^ll???<f??_1?mo;Os??b???v???T?*OH????b?dv???? | |
K? )?h?V_?W_p?L?n.Ӹz?????{?T??????&N3rF??7Uo:?W~?YX???*?z p(DK? | |
n? ??ʆD?1?#AS????iz?{?[Ui- | |
?z?aֽq?D?.ZW ?? | |
?xԉ?|?'?!/~?܊?\y?K??F??[hLB?Q? | |
?$q?RJ?{?t??]?/?? Kܪ????Q־u?{?g|???*??C}?oMڳ\N?} ?:i$\*???v?f?Ĉ$ ??9?[h<M?2???? | |
????y????η?<~?qki??i??-???i??e ????ެC?=G?;}?71{ *?9*?6??-0?+??????????6Aӑ???\??F㐂?N?m???I???????MIT????????=%?:?EP?E??????4'{?jLx????6?u?]c?/I&? | |
?y?N??D?#C?Q{/ٽuy??-`? 5????D?7&???S{W??I# 3?|"?? | |
[?5?V?m?B,N??:?????e'??o?]????ԩ8B??o~???)?E??R?f??????????ه?t?H??BF?a{?w??8???$ji?ʵlT??rӳ?1?{????>??㊪???k? | |
??ؿMǓ???K??0?[?<?3I D?{j?72/????x????? | |
?%??-px+j??G?S?c7?wl<YO͒"y A>?Ol?ch?_??eo??cS홹?YYyn??$c@?? | |
?????EQ?tHSO?v?X??O?????WA????s?B&??8?QA??s?I??~?w?WO+z??? ?*n~?w ??&?x?p@??O??9-??ʂ^?}???P???? | |
52 | |
'?'N???R?~?ׯ*?~??}??`,???????@??x&?#??????s?~S?B??7?4?:?????9??VNF:?L1]J??H??Z?x?E??????vo??`&?A??+s?@[?=I?\??a??-pՔno]??=?k???Ҽu?[_u??P???? 6??PL?9?vCq?4???Y?????Sq??z?̙U?:??&????}Pe4??? ?J?M2?[Q?p,?u-%?{~?G7?l???UE7?/?v?R<?:??>t9??H??4???=_.??E??$?E??~??Q????????f??òE??n??c???O???I0???????;W?q;?y?^??#?=?????????H???7F??m~?UkD??^?\???%?D??c?Ֆx,?7?Y}{XU?Y???$V*Ah?5??qqNFY??H~?Z?fƺ???C(a7K%??xK}?L?? | |
???lg?=:??d;???ج???<? | |
?ƍ%????>/uf???=۽??[?????W?3hZ?a?k??x??Q?¦.k???`??????w,????$???a?`=?????o?(?bq??`?!?? | |
?kk?? Ş51"??P?e-?S??E???Ƽ"????:Qx?`-?????N?ԷM'F?Y-?"?bF凍p???? | |
?J_pu?҆O?!?qx???t~Ԕ??u??+?"@?????Cg?io?F?+?($? ?H?@?f?k???PO?}.v'?C|?????#??'?~$ 8ohƧ?j2?c?? | |
?E2??CL?4;r<~?M.?؉~??P,5?v֩???Āy?ښ?|d?-???_??.ܶ9?X???&??GP7?֔?"iH,n????AU?A?O?qq?D??c?G?ij??p?? | |
\j??v?V???o??6ʾ?x??a?#p|Ej | |
Q??,5??Aǰ?-?Г???7??? | |
FӺC???ir?/??"?????s;?Җvf%??=)??$?-5T?ύ$y?`'?5???o?dȟL3??ᣥ???????????ЀI`6???=<??-????A@1?Mg????5???X?????]N??!?????p,=??c??k??O?v??Gˏ????"???T?<?o?E~b?????????Nx? | |
?Az??}+??Ne;? | |
???????(?@?Qj_A???G>!??s?a????m??? | |
?s???$[??>= ꔙ??j??E | |
4/??FA???ĕg?,C(>??????og????ƝzėYv????Mr4???m? | |
8?[?i3?s֘K?5??:??{c!?+?6Px(?k?m}??G???H????X?ciJ | |
Asa???0b6???z????????!??Tmyi?Q??A?????k?|iV?i?J?????j8??Įm???óRߕ??u?]}%[m?8??q\????H?Q?!????֬??O}o?? | |
????5??0???Y?????i?<?۠???EU?ԝm? ܤR?b?zD?N??T???????gԒ??<??#|&????????`?n??1S*x~?"????#??? ???t??L'?)??{*???????174?? | |
??=?iᜏoջ???]?!??6D????*=?q???D??8E?D???$?S????n??????'O}????p??ɥr??G?}???????g]+?:ޕ?VwՅDJm#?w????5???ϗ??S???d??֙??#??w?sҹWJ?sAu???<?t???Q???V?z<}d?k????č????Z?? | |
?@??? | |
?h???:????? | |
???|a?m=???????(???2?^?0??QEH.(?j/?_eD??? | |
------------------------------c80643c7bdcc-- | |
[30511:ERROR] 2011-05-16 09:59:30 :: bad content body | |
[30511:ERROR] 2011-05-16 09:59:30 :: /Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/rack-1.2.2/lib/rack/utils.rb:495:in `parse_multipart' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/params.rb:35:in `retrieve_params' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/params.rb:25:in `block in call' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/validator.rb:40:in `safely' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/params.rb:24:in `call' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/async_middleware.rb:74:in `call' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/tracer.rb:18:in `call' | |
/Users/chrisd/work/slapichop/lib/goliath/rack/async_middleware.rb:74:in `call' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/rack-1.2.2/lib/rack/content_length.rb:13:in `call' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/async-rack-0.5.1/lib/async_rack/async_callback.rb:114:in `call' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/async-rack-0.5.1/lib/async_rack/async_callback.rb:91:in `block in new' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/rack-1.2.2/lib/rack/reloader.rb:44:in `call' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/rack-1.2.2/lib/rack/reloader.rb:44:in `call' | |
/Users/chrisd/work/slapichop/lib/goliath/request.rb:134:in `process' | |
/Users/chrisd/work/slapichop/lib/goliath/connection.rb:57:in `block in post_init' | |
/Users/chrisd/work/slapichop/lib/goliath/connection.rb:63:in `call' | |
/Users/chrisd/work/slapichop/lib/goliath/connection.rb:63:in `<<' | |
/Users/chrisd/work/slapichop/lib/goliath/connection.rb:63:in `receive_data' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run_machine' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:199:in `run' | |
/Users/chrisd/.rvm/gems/ruby-1.9.2-p0@goliath/gems/em-synchrony-0.3.0.beta.1/lib/em-synchrony.rb:26:in `synchrony' | |
/Users/chrisd/work/slapichop/lib/goliath/server.rb:72:in `start' | |
/Users/chrisd/work/slapichop/lib/goliath/runner.rb:222:in `run_server' | |
/Users/chrisd/work/slapichop/lib/goliath/runner.rb:156:in `run' | |
/Users/chrisd/work/slapichop/lib/goliath/application.rb:84:in `run!' | |
/Users/chrisd/work/slapichop/lib/goliath/application.rb:102:in `block in <module:Goliath>' | |
[30511:INFO] 2011-05-16 09:59:30 :: trace.start:1983.41, total:1983.41 | |
[30511:INFO] 2011-05-16 09:59:30 :: trace.start:1983.41, total:1983.41 | |
[30511:INFO] 2011-05-16 09:59:30 :: Status: 500, Content-Length: 28, Response Time: 1984.26ms | |
[30511:INFO] 2011-05-16 09:59:30 :: closing connection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
$:<< 'lib' | |
require 'goliath/runner' | |
require 'goliath' | |
require 'em-mongo' | |
require 'em-http' | |
require 'em-synchrony/em-http' | |
require 'yajl/json_gem' | |
# ---------- Authorization Middleware ---------------------- | |
# Example demonstrating how to use a custom rack builder with the | |
# Goliath server and mixing Goliath APIs with normal Rack end points. | |
# | |
# Note, that the same routing behavior is supported by Goliath, loost at | |
# the rack_routes.rb example to see how to define custom routes. | |
class Slapichop < Goliath::API | |
use Goliath::Rack::Tracer, 'X-Tracer' | |
use Goliath::Rack::Params # parse & merge query and body parameter | |
# Rack end point | |
map '/photos' do | |
use ::Rack::ContentLength | |
run Photos.new | |
end | |
# catch the root route and return a 404 | |
map "/" do | |
use ::Rack::ContentLength | |
run Proc.new {|env| [404, {"Content-Type" => "text/html"}, ["Try /images /sources or /foods"]] } | |
end | |
def on_headers(env, headers) | |
env.logger.info 'received headers: ' + headers.inspect | |
env['async-headers'] = headers | |
end | |
def on_body(env, data) | |
env.logger.info "DATA SIZE: #{data.size}" | |
if data.size > 9_000 | |
env.logger.info "received something bigger than 9kb" | |
else | |
env.logger.info "body data:" + data | |
end | |
end | |
def on_close(env) | |
env.logger.info 'closing connection' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment