pkunc has quit [Read error: Connection reset by peer]
pkunc has joined #nanoc
tantalum has joined #nanoc
<guardian>
bobthecow: the man who knows a lot, do you know by chance why Ruby Net::HTTP has both request_post and post methods?
<bobthecow>
guardian: post (the old one) yields response fragments.
<bobthecow>
post2 (or request_post) yields the response.
<bobthecow>
the old one is still there for backwards compatibility, but you'd likely never use it unless you're streaming enormous responses from posts and need to write them to disk incrementally or something.
<bobthecow>
the real question, though, is why you're not using httparty instead of Net::HTTP?
<bobthecow>
abstractions exist for a reason ;)
<guardian>
I don't know httparty
<guardian>
there's rest-client
<guardian>
there's nestful
<bobthecow>
there are a lot of 'em.
<bobthecow>
the fact remains that you're using Net:HTTP when there are much better HTTP abstractions out there :)
<guardian>
bobthecow: I don't get the difference between response fragment and response. Documentation says both request_post and post return an HTTPResponse object
<guardian>
yeah but I'm also learning :)
<guardian>
also I can't use request_post or post anyways since I need to req.basic_auth 'user', 'pass'
<bobthecow>
look at the block in that code sample.
<bobthecow>
it's receiving the response a string at a time.
<bobthecow>
and writing each fragment to f.
<guardian>
ah yeah that's when using a block
<guardian>
but if you don't use a block there's no difference right?
<guardian>
apart from the deprecated destnil param
<guardian>
dest param
<bobthecow>
"yields response fragments" means "when using a block". that's what yield is ;)
<guardian>
bobthecow: while I'm at it, and then I'll stop substituting you for #ruby: I find weird people use instance variables in plain ruby scripts, is this common in Ruby land?
<guardian>
I would have written "user = ..." and not "@user = ..." because I'm not in a class, hence there's no such thing as an instance variable
<bobthecow>
but there is, and you are :)
<bobthecow>
everything's an object in ruby, remember?
<guardian>
well yes, still looks weird to me
<guardian>
I better look at user being a local variable of the main method, than an instance variable of the instance that happens to own the main method
<bobthecow>
i don't particularly have strong feelings one way or another. if i were writing it i'd use local variables.
<guardian>
ok
<guardian>
thx bobthecow
<bobthecow>
no problem.
<guardian>
looking into httparty but well I'm not sure it brings much compared to what I really need
<guardian>
at least it's not less verbose to POST json using httparty than with net/http
<bobthecow>
httparty is about encapsulating related requests into something you can reason about and work with.
VitamineD has quit [Ping timeout: 245 seconds]
cDlm has joined #nanoc
FabianB has joined #nanoc
leobalter has left #nanoc ["tchau"]
FabianB_ has quit [Ping timeout: 252 seconds]
<ddfreyne>
I found Net::HTTP to be the most reliable.
<ddfreyne>
People say a lot of nice stuff about Faraday, but its API is unpredictable.
pkunc has quit [Ping timeout: 255 seconds]
tantalum has quit [Quit: Leaving]
pkunc has joined #nanoc
pkunc has quit [Quit: Leaving.]
srbaker has quit [Remote host closed the connection]