Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:12
    HertzDevil labeled #13052
  • 18:12
    HertzDevil labeled #13052
  • 18:12
    HertzDevil labeled #13052
  • 18:12
    HertzDevil opened #13052
  • 17:49
    straight-shoota closed #13051
  • 17:46
    beta-ziliani milestoned #13051
  • 17:46
    beta-ziliani milestoned #13051
  • 14:03
    beta-ziliani review_requested #13050
  • 13:59
    straight-shoota labeled #13051
  • 13:59
    straight-shoota assigned #13051
  • 13:59
    straight-shoota opened #13051
  • 13:50
    straight-shoota milestoned #13050
  • 13:50
    straight-shoota milestoned #13050
  • 13:47
    Blacksmoke16 labeled #13050
  • 13:47
    Blacksmoke16 labeled #13050
  • 13:47
    Blacksmoke16 labeled #13050
  • 13:47
    Blacksmoke16 labeled #13050
  • 13:39
    bcardiff opened #13050
  • 10:33
    straight-shoota closed #12965
  • 10:33
    straight-shoota closed #12966
From IRC (bridge bot)
@FromIRC
<SamantazFox> my problem is that response.body is a String, and I have to feed it to Compress::Gzip::Reader
George Dietrich
@Blacksmoke16
body_io is only set if you're using the block version of one of the request methods
From IRC (bridge bot)
@FromIRC
<SamantazFox> So I though: let's use response.body_io instead, to directly have an IO
George Dietrich
@Blacksmoke16
From IRC (bridge bot)
@FromIRC
<straight-shoota> There is no way to access either body or body_io. They're mutually exclusive
<SamantazFox> That's something I'd expect, yeah, but why body is always the full body, as a String and body_io is that same body as IO, but Nil on Docker?
<straight-shoota> Sorry what has Docker to do with this?
<SamantazFox> I'm trying to figure that out, actually.
<SamantazFox> For context, I've made this code, to prevent an issue from happenning: https://github.com/iv-org/invidious/pull/2623/files
<SamantazFox> Said issue is: "body is sometimes decompressed, sometimes not"
From IRC (bridge bot)
@FromIRC
<SamantazFox> So, I've set "Content-Encoding" to "gzip, deflate" to disable HTTP::Client's auto-decompression, and added the required logic to decompress the body by myself
<SamantazFox> problem is that when deployed on bare-metal, it works fine, and on Docker, we're getting this: iv-org/invidious#2632
George Dietrich
@Blacksmoke16
i mean is it not possible you're doing like HTTP::Client.get "..." then trying to access body_io on it?
From IRC (bridge bot)
@FromIRC
<SamantazFox> response.body_io, yes.
George Dietrich
@Blacksmoke16
response = HTTP::Client.get("...")
response.body # okay
response.body_io # not okay

HTTP::Client.get("...") do |response|
  response.body # not okay
  response.body_io # okay
end
From IRC (bridge bot)
@FromIRC
<SamantazFox> Why is it "not okay"?
<SamantazFox> oops, wrong link
<SamantazFox> better
George Dietrich
@Blacksmoke16
because body_io is only set in the context of using the block overload, so body wouldnt be set
while if you used the non block overload body is set and body_io is not
by "not okay" meaning it'll raise saying it shouldn't be nil
if you try to use it in not the right context
From IRC (bridge bot)
@FromIRC
<SamantazFox> Oh, I misunderstood the code snippet you provided
<SamantazFox> Ok, I get it now.
<SamantazFox> Why isn't that mentionned in the API doc?!
George Dietrich
@Blacksmoke16
From IRC (bridge bot)
@FromIRC
<SamantazFox> Ok, thanks y'all
<SamantazFox> Now, I'm wondering why it works sometimes, and not others.
<SamantazFox> And of course impàlement that properly
From IRC (bridge bot)
@FromIRC
<SamantazFox> What's the most recommended? Foo::Bar.echo or Toto::Foo::Bar.echo
George Dietrich
@Blacksmoke16
probably doesnt really matter, could argue the former since its shorter, or the latter because its more clear what specific type it points to
j8r
@jrei:matrix.org
[m]
In rare cases you have no choice of the latter if the stdlib uses the same name
From IRC (bridge bot)
@FromIRC
<SamantazFox> mmmh, okay, thanks :⁠)
Paulo Coghi
@paulocoghi
@naqvis Wow!
Ali Naqvi
@naqvis
:+1:
From IRC (bridge bot)
@FromIRC
<spuun> I have a MetaVar (from @type.instance_vars) which i know is a Hash, but i want to get the key and value types. How? I want to go from the MetaVar to a HashLiteral, I think?
From IRC (bridge bot)
@FromIRC
<spuun> type.type_vars is enough
George Dietrich
@Blacksmoke16
:thumbsup:
Paulo Coghi
@paulocoghi
newbie question: Is it possible to dynamically call an instance method, passing the instance variable name by string?
George Dietrich
@Blacksmoke16
not built in, but it's technically possible to re-create
there is no#send like in Ruby, but id consider redesigning it so you dont need to do that?
Max Fierke
@maxfierke
https://github.com/wyhaines/Send.cr is one such approach to dynamic dispatch in Crystal
Paulo Coghi
@paulocoghi
I am implementing this concept in Crystal (from FeathersJS framework):
hook-flow-3-service.jpg
A library where you can "register" services (that is, class instances) with defined "expected" methods
The main library allow the "registration" of one or more instances
The classes are created by the developer, which must have one or more methods (from the expected ones)