jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
sagax has quit [Ping timeout: 260 seconds]
chloekek has quit [Remote host closed the connection]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
davic has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 260 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
sagax has joined #crystal-lang
renich has joined #crystal-lang
<renich> Hello! o/
<renich> I am trying to write a "one-liner" for a web server in my GNUMakefile so that crystal serves my html website for previewing. I got this from the docs: crystal eval 'require "http/server"; server = HTTP::Server.new( [HTTP::ErrorHandler.new, HTTP::LogHandler.new, HTTP::CompressHandler.new, HTTP::StaticFileHandler.new("web/")] ); server.bind_tcp "127.0.0.1", 12345; puts; puts "La página está disponible en: http://localhost:12345/ind
<renich> ex.html"; puts "Presiona Ctrl + c para detenerlo..."; puts; server.listen'
<renich> The only problem is that it doesn't set the content-type header correctly. I'd like to have: Content-type: text/html; charset: utf8;
<renich> I tried using the HTTP::Server::Response object, but didn't quite figure it out.
renich has quit [Quit: Leaving.]
<FromGitter> <HertzDevil> > Because it defined functions, not methods. They don't share a state ⏎ ⏎ not true, it defines methods on the module's metaclass
<FromGitter> <HertzDevil> every class is an instance of its own metaclass
<FromGitter> <HertzDevil> this is even more the case in ruby where hooks like `extended` are regular methods and dynamic classes are possible
gangstacat has quit [Quit: Ĝis!]
chloekek has joined #crystal-lang
ua has quit [Ping timeout: 260 seconds]
ua has joined #crystal-lang
alexherbo2 has joined #crystal-lang
gangstacat has joined #crystal-lang
r0bby has quit [*.net *.split]
<FromGitter> <Blacksmoke16> looks fine to me renich ?
<FromGitter> <Blacksmoke16> or do you mean its missing the `charset: utf8;` part?
r0bby has joined #crystal-lang
r0bby has quit [Ping timeout: 246 seconds]
psydroid has quit [Ping timeout: 240 seconds]
return0e[m] has quit [Ping timeout: 244 seconds]
ryanprior has quit [Ping timeout: 244 seconds]
r0bby has joined #crystal-lang
psydroid has joined #crystal-lang
ryanprior has joined #crystal-lang
return0e[m] has joined #crystal-lang
duane has joined #crystal-lang
teardown has quit [Ping timeout: 240 seconds]
teardown has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <vinyll> Hey guys! ⏎ I'm looking to do a basic file download and save in Crystal. ⏎ As a noob, I end up with an unreadable file… ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5fb01edab4283c208a656378]
<FromGitter> <Blacksmoke16> just do this
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fb01f59b86f6407044f16e4]
<FromGitter> <Blacksmoke16> then you dont even load any of it into memeory
<FromGitter> <Blacksmoke16> memory
<FromGitter> <Blacksmoke16> `.body_io` is only available when using the block version, see https://github.com/crystal-lang/crystal/issues/9901 and https://github.com/crystal-lang/crystal/issues/9900
<FromGitter> <vinyll> Wow, that's something I would not have expected
<FromGitter> <vinyll> Thanks for the quick help, it just works 👍
<FromGitter> <Blacksmoke16> np
<FromGitter> <asterite> Wow, I can't believe so many people get tripped by this, and why there is such a big resistance to fix it for good
<jhass> is there? so far I think only brian objected to get rid of body_io, for the rest of us we just can't quite agree on how to fix it :P
<FromGitter> <vinyll> Funny enough this is my first script in Crystal and I face this trap after 20 lines of code ^^
<FromGitter> <asterite> Well, resistance to my specific proposal :-P
<FromGitter> <asterite> (which makes things type safe and obvious)
<FromGitter> <asterite> I'm also surprised by Brian's rejection. Give his Haskell and functional background, I'm surprised he didn't like the variants approach, which is the most type safe way to model this
teardown has quit [Ping timeout: 240 seconds]
teardown has joined #crystal-lang
<FromGitter> <j8r> @asterite Sometimes, a discussion which involves lots of small replies is not well suited for text. ⏎ Then, the topic looks more complex as it is. ⏎ I'm pretty sure a call meeting with the core team can settle this rather quickly.
<FromGitter> <j8r> That's my experience overall 😉
<raz> i think i like the "always IO" option best. no surprises.
<raz> but not a big fan of that
<raz> otoh i also like the idea of having a smarter method that raises on bad http code, perhaps smartly switches to a tempfile for huge replies, handles timeouts (connection vs fifst-byte vs transfer vs duration) etc.
<raz> these are the types of things that otherwise everyone rolls themselves poorly until some defacto standard 3rd party library emerges
<FromGitter> <j8r> I'd be fore having only the block variant
<raz> j8r: yea, i kinda like that idea, too. just wonder how it might interfere when you really just want to grab the IO and pass it around to be handled elsewhere
<FromGitter> <j8r> IMHO there are too much methods in `HTTP::Client`, to basically do the same thing
<FromGitter> <j8r> because the block variant close at the end...
<FromGitter> <j8r> good point
<raz> yep, not sure if it's a realistic scenario, but i imagine it could make it a bit more tricky when you want to juggle long-lived connections (spawn a few, hand off to worker fibers etc.)
<raz> then again... can't really think of an actual use-case where i'd want to do that
<FromGitter> <j8r> raz: in fact; not
<raz> (and where i couldn't just run the whole block in the worker fiber)
<FromGitter> <j8r> if one want something specific: `HTTP::Client.new`
<raz> indeed
<FromGitter> <j8r> `HTTP::Client.get` I think close the connection, and puts the body in a string
<FromGitter> <j8r> that's why there are IO errors
<raz> hm hm, yea i haven't really used it enough to truly judge. i went straight to https://github.com/mamantoha/crest for my http client dabblings
<FromGitter> <j8r> I don't like this rubyism `{:lang => "en"}` :(
<raz> but perhaps there's a case to be made for keeping HTTP::Client "raw" anyway (as in "always IO") and leave those fancy pants to a 3rd party shard
<FromGitter> <j8r> the only, main pros is for following redirections
<raz> ya well i haven't used crest for super-fancy stuff, but for the basics it felt alright. i was in particular glad it has timeout handling so i didn't have to think about it
<FromGitter> <j8r> https://crystal-lang.org/api/master/HTTP/Client.html#connect_timeout=(connect_timeout:Number)-instance-method
<FromGitter> <j8r> maybe there are more timeouts available in your lib...
<FromGitter> <j8r> anyway, get your point
<raz> oh ok, ha. yea nah, looks like crest is just passing those through
<FromGitter> <Blacksmoke16> https://athena-framework.github.io/athena/Athena/Routing/Spec/APITestCase.html merged in an Athena feature to allow more easily integration testing your controllers; including mocking out services for the tests
<FromGitter> <Blacksmoke16> Doesn't spawn an `HTTP::Server` so should be more reliable/faster than equivalent tests
<raz> Blacksmoke16: https://carc.in/#/r/9yhy
<raz> wink wink nudge
<FromGitter> <Blacksmoke16> :thinking: what am i looking at here?
<raz> testing incl. routing without spawning a server or involving the network
<FromGitter> <Blacksmoke16> fair enough 😉
<FromGitter> <Blacksmoke16> prob not as straightforward if you have a framework in front of `Quasi`
<straight-shoota> > just wonder how it might interfere when you really just want to grab the IO and pass it around to be handled elsewhere
<straight-shoota> raz, there could definitely be a low-level API for that. For example `exec` could return a response
<FromGitter> <ImAHopelessDev_gitlab> hi
<FromGitter> <3n-k1> is there an oauth server library in crystal? i can't find anything and i would rather not write one myself haha
<FromGitter> <Blacksmoke16> not that i know of, only have seen the client side of things
zorp has quit [Read error: Connection reset by peer]
erdnaxeli has joined #crystal-lang