jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
pawnbox has joined #crystal-lang
<asterite> RX14: we should probably split HTTP::Request in two, yeah... I also thought about that recently. The server request would have an IO from which you can read, and for the client we could probably have a post_io or similar that would give you an IO that you can write to, and eventually execute the request (optionally providing a block to read the response as an IO)
<RX14> yup
<RX14> i would make an issue but it's 1am
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
bjz has quit [Client Quit]
nakilon has quit [Quit: WHY NOT?]
soveran has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 252 seconds]
willl has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
ponga has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
onethirtyfive has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 276 seconds]
matp has joined #crystal-lang
ome has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 260 seconds]
kulelu88 has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaun_ has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
Oliphaun_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 244 seconds]
tomchapin has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
onethirtyfive has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
kulelu88 has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
mark_66 has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox_ has quit [Ping timeout: 276 seconds]
pawnbox has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
snsei has quit [Ping timeout: 265 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
bjz has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
willl has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
ponga has joined #crystal-lang
<FromGitter> <sdogruyol> what does this mean? `@a : T*? = nil`
<FromGitter> <sdogruyol> especially T*
<jhass> T* is Pointer(T)
<FromGitter> <sdogruyol> oh, now i see
<BlaXpirit> sdogruyol, hm it's a bit strange to use `?` with a pointer, because you could use null instead
<FromGitter> <sdogruyol> guess so
<BlaXpirit> >> a = Pointer(Int32).null; p !!a
<DeBot> BlaXpirit: false - more at https://carc.in/#/r/1573
<FromGitter> <sdogruyol> T*? feels a bit strange
ome has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mark_66 has quit [Quit: Leaving.]
mark_66 has joined #crystal-lang
mark_66 has quit [Read error: Connection reset by peer]
mark_66 has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> ugh, isn't there a way to get the full_path of a HTTP::Request
<FromGitter> <sdogruyol> like abc.xyz.com/api/v1/users
<FromGitter> <sdogruyol> not just resource but the full name with abc.xyz.com
<jhass> well, technically the request doesn't have to know the host
<jhass> in practice you can reconstruct it from the Host header
<FromGitter> <kofno> I wonder why uri is private on requests?
<FromGitter> <sdogruyol> hmm
<jhass> because it's an implementation detail
<FromGitter> <kofno> Seems like that request should expose more details then
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<FromGitter> <kofno> but yeah, it looks like the current request impl will require you to wrangle headers.
snsei has quit [Ping timeout: 258 seconds]
<FromGitter> <sdogruyol> how does Rack handle stuff like this?
<RX14> what are you trying to do?
<FromGitter> <sdogruyol> getting the current full uri
<FromGitter> <sdogruyol> abc.xyz.com for example
<FromGitter> <sdogruyol> i've managed to get that from request.headers["Host"]
<FromGitter> <sdogruyol> but not sure if it's the best way
<RX14> it's the only way
<RX14> i mean, how else would you get it
<RX14> how is a TCP connection meant to know what dns query returned it's ip
<FromGitter> <sdogruyol> dunno, maybe read from the underlying socket?
<RX14> the Host header is the only way UAs report which hostname they used to get to the site
trapped has joined #crystal-lang
<FromGitter> <kofno> rack has a bunch of helpers on the request object and they read from the headers.
<FromGitter> <sdogruyol> so they also rely on headers
<FromGitter> <sdogruyol> i see
<RX14> well it IS the only way
<FromGitter> <kofno> so, `request.host` reads the host headers
<FromGitter> <kofno> yeah... it's the only way. My point was just that maybe the request object could help out with common headers.
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> request.host is definitely nicer
<FromGitter> <kofno> because that might also contain a port number and such.
<FromGitter> <kofno> so, rack actually has host and host_with_port and takes care of that for you
<FromGitter> <sdogruyol> cool
<RX14> looks like it's just hopstname then optional :port
<RX14> so you can split(':', 2) and go
<FromGitter> <kofno> right, but why make _everyone_ do that? Just encode it into the request object.
<RX14> i didn't mean to say that
<RX14> i was just looking up if the host header had any ambiguous syntax i didn't nkow about
<FromGitter> <kofno> oh... then nope :)
<FromGitter> <kofno> just host name and maybe the port
<FromGitter> <sdogruyol> how about a PR then :D
<FromGitter> <kofno> OK... so rack looks in a few headers
<FromGitter> <kofno> Web programming... smh... :)
<FromGitter> <sdogruyol> haha
<RX14> according to HTTP/1.1 the Host header is required
<RX14> so it technically should be on every request
<FromGitter> <sdogruyol> hmm
<RX14> it can be empty though
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<jhass> also if maybe not vetted support yet, we do have some conditionals to support HTTP/1.0 still
<FromGitter> <sdogruyol> why
<jhass> just saying, I didn't put them there
<FromGitter> <kofno> well, host is required, but the request may be forwarded, in which case rack gives you the forwarded address instead of the proxy host. Apparently.
bjz has joined #crystal-lang
<FromGitter> <sdogruyol> i think we can port this Rack impl to Crystal
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 264 seconds]
soveran has quit [Remote host closed the connection]
trapped has quit [Read error: Connection reset by peer]
pawnbox has quit [Remote host closed the connection]
mroth has quit [Read error: Connection reset by peer]
jwaldrip has quit [Read error: Connection reset by peer]
daemonwrangler has quit [Read error: Connection reset by peer]
ponga has quit [Read error: Connection reset by peer]
danzilio has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
iamstef has quit [Read error: Connection reset by peer]
emmanueloga has quit [Read error: Connection reset by peer]
aemadrid has quit [Read error: Connection reset by peer]
danzilio has joined #crystal-lang
fedruantine has quit [Ping timeout: 260 seconds]
mroth has joined #crystal-lang
Oliphaunte has joined #crystal-lang
jwaldrip has joined #crystal-lang
daemonwrangler has joined #crystal-lang
<jeromegn> how would I go about JSON.mapping something like {“a_key”: {“value”: “the value”}} to object.a_key == “the value”? I tried with JSON.mapping(a_key: {type: String, key: “a_key.value”}) but I get https://play.crystal-lang.org/#/r/1577
ponga has joined #crystal-lang
Philpax has quit [Ping timeout: 252 seconds]
<jeromegn> I’ll probably have to write a macro if I want to parse that nicely eh?
fedruantine has joined #crystal-lang
iamstef has joined #crystal-lang
emmanueloga has joined #crystal-lang
matp has quit [Remote host closed the connection]
aemadrid has joined #crystal-lang
<jeromegn> tempted to create a class that will forward missing stuff to its @value...
<jhass> jeromegn: you can do something like https://play.crystal-lang.org/#/r/157a
<jeromegn> ohh
<jeromegn> that’s nice
matp has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
<Yxhuvud> split ':', 2 doesn't support ipv6 though
<Yxhuvud> or is raw ip numbers not possible there?
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<BlaXpirit> SF :p
rolha has joined #crystal-lang
<FromGitter> <kofno> that's what I meant :p
snsei has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
snsei has quit [Ping timeout: 260 seconds]
ponga has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <jwoertink> These links to the `play.crystal-lang.org` aren't working on firefox for OSX. Should I post an issue on the main repo? Or is there a separate repo for that?
<FromGitter> <cjgajard> https://github.com/jhass/carc.in might be? idk
<RX14> it's carc.in repo you should be making an issue for
<jhass> please tell more than "not working" though
<FromGitter> <jwoertink> will do
snsei has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
<crystal-gh> [crystal] sdogruyol opened pull request #3075: Add HTTP::Request#host and HTTP::Request#host_with_port for convenience (master...master) https://git.io/v6f05
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Raimondi has quit [Quit: WeeChat 1.6-dev]
rolha has joined #crystal-lang
Oliphaunte has joined #crystal-lang
triangles has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 250 seconds]
Oliphaunte has joined #crystal-lang
Raimondi has joined #crystal-lang
kulelu88 has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 244 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] ysbaddaden opened pull request #3076: Socket refactors (master...std-socket-refactors) https://git.io/v6Jem
<FromGitter> <splattael> a dump question: How do I actually copy a string so it won't get modified using `Slice` methods? Currently I'm doing: `slice = String::Builder.new(string).to_s.to_slice`
<FromGitter> <splattael> dumb* ;))
<jhass> .dup.to_slice ?
<jhass> dunno, do we have String#dup actually?
<jhass> >> "foo".dup
<DeBot> jhass: # => "foo" - https://carc.in/#/r/157s
<jhass> >> a = "foo"; b = a.dup; {a.object_id, b.object_id}
<DeBot> jhass: # => {134704704, 134704704} - https://carc.in/#/r/157t
<jhass> mmh
<jhass> >> s = "foo"; b = Slice(UInt8).new(s.bytesize).copy_from(s.to_unsafe, s.bytesize); b
<DeBot> jhass: # => Pointer(UInt8)@0x94fcfe8 - https://carc.in/#/r/157u
<jhass> >> s = "foo"; b = Slice(UInt8).new(s.bytesize); b.copy_from(s.to_unsafe, s.bytesize); b
<DeBot> jhass: # => Slice[102, 111, 111] - https://carc.in/#/r/157v
<jhass> I guess
<FromGitter> <splattael> yeah, `dup` and `clone` has been changed in e7bc74b so `String#dup/clone` won't work anymore
<FromGitter> <splattael> jhass, maybe a `String#copy` would be handy which would your impl above? :)
<jhass> it's an edgecase usage
<jhass> strings are immutable by default, if you modify the underlying slice that's kinda unsafe and your problem
<jhass> mh, how odes Slice#dup/clone behave?
<jhass> I can see that returning an actual copy of the data
<FromGitter> <splattael> it does not work: https://carc.in/#/r/157x it is still modifying the original string
<FromGitter> <splattael> jhass, "#{string}" would also work to copy a string but looks hacky
<jhass> why do you modify it anyway?
<FromGitter> <splattael> to speed up things :-)
<jhass> that's a non-answer...
<FromGitter> <splattael> to avoid creating strings over and over again by using slice
<FromGitter> <splattael> note, the code above has been ported from ruby (with all its consequences)
<FromGitter> <splattael> `_shuffle` is "just" swapping some chars. no need to create new strings over and over again -> slice to the rescue :)
<FromGitter> <splattael> jhass, the point, I do not want to modify the original string (`alphabet`) but it gets modified by using `Slice` because it's unsafe and therefore my probem, I know :-)
<jhass> String.build do |builder| ... builder.buffer[j] = slice[i]; builder.buffer[i] = slice[j]
<jhass> String.build(alphabet.bytesize)
<FromGitter> <splattael> ah yes, that would work because all indexes are hit
<FromGitter> <splattael> jhass, thank you!
<jhass> yw
Oliphaunte has quit [Remote host closed the connection]
<FromGitter> <splattael> jhass, what am I doing wrong here? https://carc.in/#/r/1580
<FromGitter> <splattael> `new_string` should read "eeee"
<jhass> oh, mh
<jhass> @bytesize needs to increase which there's no public API for beyond write :/
<jhass> (and the IO stuff that uses it)
<jhass> still a bit nicer API I think
<FromGitter> <splattael> yes, idiomatic Crystal is hard for me
<FromGitter> <splattael> it's getting better though :)
<FromGitter> <splattael> jhass, again thank you so much for your help <3
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ponga has quit [Quit: Connection closed for inactivity]
<jeromegn> what’s the idiomatic way of blocking a crystal program so that its spawned fibers can continue for as long as needed? right now I’m adding a very long sleep a the end of my program.
<RX14> sleep with no argument
<RX14> sleeps forever
<FromGitter> <jwoertink> lol oops!
<FromGitter> <jwoertink> hmm.. it does that in ruby too apparently
<RX14> it just calls Scheduler.reschedule
<RX14> in crystal
<RX14> which never returns
<RX14> which is nice
<FromGitter> <jwoertink> It's interesting what I've learned about ruby from using crystal