Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6-lwp-gsoc, 2014-06-05

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
01:34 FROGGS_ joined #perl6-lwp-gsoc
04:33 FROGGS_ joined #perl6-lwp-gsoc
05:15 FROGGS_ joined #perl6-lwp-gsoc
06:43 sergot morning o/
07:15 sergot moritz: I think naming is not so important, so I'll just continue as it is. :)
08:07 FROGGS_ joined #perl6-lwp-gsoc
08:20 dalek http-simple: 1553f84 | sergot++ | / (7 files):
08:20 dalek http-simple: init
08:20 dalek http-simple: review: https://github.com/sergot/http-simple/commit/1553f84144
08:21 dalek http-simple: d2ed9e0 | sergot++ | / (6 files):
08:21 dalek http-simple: bin moved to bin/
08:21 dalek http-simple: review: https://github.com/sergot/http-simple/commit/d2ed9e0e21
08:26 sergot What do you think about HTTP::Get for the simpliest HTTP client?
08:26 sergot I mean for p5's LWP::Simple
08:26 moritz I wouldn't actually write a separate module for that
08:27 moritz just an export tag :simple, so you can say   use HTTP::Client :simple;
08:27 moritz and that exports a few "simple API" functions
08:27 moritz but you can still use HTTP::Client objects with the same import
08:28 sergot And by HTTP::Client do you mean LWP::UserAgent?
08:29 sergot I feel a little bit lost. :)
08:30 moritz the question is how to provide the functionality that p5's LWP::Simple provides, right?
08:30 sergot That's right
08:30 moritz so, my answer is
08:30 moritz you're writing HTTP::Client or HTTP::UserAgent or whatever it's called as usual
08:31 moritz and then, to that module, you also add the "simple" functions like get(), getstore()
08:31 moritz but you don't export them by default, you say  sub get($url) is export(:simple);
08:31 moritz so, the user only gets those functions when they say   use HTTP::UserAgent :simple;
08:31 moritz but they still have the full power of HTTP::UserAgent at hand, even if they do that
08:32 moritz so IMHO that's the best of both worlds
08:32 moritz sergot: less lost?
08:37 sergot moritz: I'm not lost anymore! thanks
08:37 sergot moritz: one more question
08:38 sergot About HTTP::Client: if it provide two functionalities (normal and simple) how should I write it, as a module or a class?
08:39 sergot I want the UserAgent-stuff to be a class, and some :simple subs to be just subs which we can import.
08:43 moritz a class has all the functionality of a module
08:43 moritz so simply write it as a class
08:43 sergot ook :)
08:43 moritz and export some subs from the class
08:47 dalek http-useragent: db676db | sergot++ | lib/HTTP/UserAgent.pm6:
08:47 dalek http-useragent: :simple tag added
08:47 dalek http-useragent: review: https://github.com/sergot/http-useragent/commit/db676db28e
08:47 sergot moritz: like that?
08:47 sergot this
08:47 sergot at the bottom
08:50 moritz sergot: yes
08:50 sergot great, thanks moritz++
13:21 dalek http-useragent: 91876be | sergot++ | / (6 files):
13:21 dalek http-useragent: .get to get() :simple, bin/http-{download, dump, request} started
13:21 dalek http-useragent: review: https://github.com/sergot/http-useragent/commit/91876be477
13:24 dalek http-useragent: 9caa27d | sergot++ | lib/HTTP/UserAgent.pm6:
13:24 dalek http-useragent: getprint :simple added
13:24 dalek http-useragent: review: https://github.com/sergot/http-useragent/commit/9caa27d434
13:35 dalek http-useragent: 472ea37 | sergot++ | lib/HTTP/UserAgent.pm6:
13:35 dalek http-useragent: head :simple added
13:35 dalek http-useragent: review: https://github.com/sergot/http-useragent/commit/472ea37db4
13:37 moritz sergot: IMHO the logic that's now in _get should really be in a class
13:38 moritz in a mmethod, more precisely
13:39 moritz sergot: so that  sub get just does a   my $ua = HTTP::UserAgent.new; my $response = $ua.get($url); die unless $response.is-success; return $response.decoded-content }
13:39 moritz or something like that
13:40 moritz (if that's obvious to you, and you just want to refactor it later, then never mind :-)
13:45 dalek http-useragent: 19de4da | sergot++ | lib/HTTP/UserAgent.pm6:
13:45 dalek http-useragent: is_success and is_error :simple added
13:45 dalek http-useragent: review: https://github.com/sergot/http-useragent/commit/19de4da70b
13:46 sergot moritz: I thought so too, thanks.
13:47 moritz sergot: I don't think sub is_success makes sense
13:47 sergot sergot: why so?
13:47 moritz sergot: in the :simple API, I wouldn't expose the HTTP:: object at all
13:47 moritz sergot: and a get() that fails just throws an exception
13:47 moritz or fail()s
13:47 sergot hmm
13:47 sergot https://metacpan.org/pod/LWP::Simple#is_success-rc
13:48 sergot moritz: I like your ideas
13:48 sergot I should write it more 6ish
13:49 sergot 15:40 < moritz>: yes, I want to refactor it later :)
13:49 moritz ++sergot :-)
14:01 sergot ;)
16:11 FROGGS joined #perl6-lwp-gsoc
16:24 sergot moritz: in topic of exceptions, should it throw exceptions like NotFound, Forbidden etc. or just HTTP::Error with response code?
16:33 [Coke] I would prefer exceptions over a special return-type-that-isn't-Failure
16:34 [Coke] or do you mean throwing HTTP:Error as an exception?
16:36 FROGGS +1 for exceptions
16:37 FROGGS since it makes it easier for the programmer... since it will explode nicely unless it is handled, which leads to saner code
16:37 moritz sergot: I think we should have two exception classes, one for connection errors, one for HTTP responses that indicate failure
16:38 FROGGS yeah
16:38 moritz but separate classes for NotFound, Forbidden, InternalServerError etc. sound excessive
16:39 FROGGS what about X::Transport... and X::HTTP ?
16:40 sergot [Coke]: yes, I meant this
16:41 sergot ok :)
16:46 dalek http-useragent: cf5dcac | sergot++ | lib/HTTP/UserAgent.pm6:
16:46 dalek http-useragent: _get moved into the class
16:46 dalek http-useragent: review: https://github.com/sergot/http-useragent/commit/cf5dcac34e
16:46 sergot I also added a prototype of an exception
16:47 sergot This one should be in HTTP::Response

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary