Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 05:54 PM, ToddAndMargo wrote:

On 07/28/2017 12:48 PM, ToddAndMargo wrote:

On 07/28/2017 04:31 AM, Gabor Szabo wrote:
On Fri, Jul 28, 2017 at 9:49 AM, ToddAndMargo  
wrote:

Hi All,

I am trying to convert a p5 program to p6.  What do I use in
place of `LWP::UserAgent`?

I use it for downloading files from the web.  I need to be able
to pass the following to the web page:

 Caller
 Host
 UserAgent
 Referer
 Cookies

This is the p5 code I want to convert:

http://vpaste.net/gtJgj

Any words of wisdom?

Many thanks,
-T


On 07/27/2017 10:30 PM, Gabor Szabo wrote:


LWP::Simple now allows you to set the header of your request.
See my recent article with examples:
http://perl6maven.com/simple-web-client
I hope this helps.

regards
 Gabor

On Fri, Jul 28, 2017 at 7:42 AM, Todd Chester 
wrote:




I see your article.  I do believe this is what I want.

{
   "args": {
 "language": "Perl",
 "math": "19+23=42",
 "name": "Larry Wall"
   },
   "headers": {
 "Connection": "close",
 "Host": "httpbin.org",
 "User-Agent": "LWP::Simple/0.090 Perl6/rakudo"
   },
   "origin": "17.19.208.37",
   "url": "http://httpbin.org/get?name=Larry
Wall=Perl=19%2B23%3D42"
}


Questions:

1) may I leave off the `args` and only include the `headers`?

2) I need an example with headers.  I have no clue what goes
before the first "{"

Many thanks,
-T


I think you quoted the response here and not the request.
What you need I think is the last example on that page.
Something like this:

my $html = LWP::Simple.new.get("http://httpbin.org/headers;, {
 "User-Agent" => "Perl 6 Maven articles",
 "Zone" => "q" }
);


Gabor




Thank you!

how do I save to a file?






And how do I get it to follow links, like `curl -L`?



I was just on the perl (5) chat line. One of the developers
uncovered the issue I was having following link in P5's
LWP::UserAgent.   The default is 7 redirects. I cough on
two because tcp dump truncates the return string (it is long).

They said they would look at it and see if they could fix it
and then eMail me.

Man I try across a lot of bugs!  



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 07:03 PM, Timo Paulssen wrote:

there's an example in the readme that goes like this:

 my $curl = LibCurl::Easy.new(:verbose, :followlocation);

the followlocation part should be right for you




I love it.  Thank you!


--
~~~
Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
~~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Timo Paulssen
there's an example in the readme that goes like this:

my $curl = LibCurl::Easy.new(:verbose, :followlocation);

the followlocation part should be right for you


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 06:55 PM, Timo Paulssen wrote:

If you use the other interface where you create a curl object a la
LibCurl::Easy.new, you can just

 $my_curl_object.Host("the-host.com");
 $my_curl_object.referer("example.com");
 $my_curl_object.cookie("the-cookie");
 $my_curl_object.useragent("me");

hth
   - Timo



That is intuitive.  I love it.  Thank you!

Anything for following links?



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Timo Paulssen
If you use the other interface where you create a curl object a la
LibCurl::Easy.new, you can just

$my_curl_object.Host("the-host.com");
$my_curl_object.referer("example.com");
$my_curl_object.cookie("the-cookie");
$my_curl_object.useragent("me");

hth
  - Timo


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 06:49 PM, Timo Paulssen wrote:

Did you not see this part of the readme?

 # And if you need headers, pass them inside a positional Hash:
 say post 'https://httpbin.org/post?foo=42=x',
%(:Some),
 :some, :42args;



Thank you.

What a nightmare to figure out.



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 06:36 PM, Bennett Todd wrote:

As for LWP being a pain, I see it differently,  filling the specs for a web 
client --- many specs --- is a pain. The curl project is trying to wrap a 
blanket around that pain.



The pain is trying to figure out how to use the various headers.
The docs are written for those that already know how to do it.

It took me two weeks of postings and research to figure out
download to a file.

It is:
':content_file' => "$FileName",
by the way.

-T


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Timo Paulssen
Did you not see this part of the readme?

# And if you need headers, pass them inside a positional Hash:
say post 'https://httpbin.org/post?foo=42=x',
%(:Some),
:some, :42args;


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 06:36 PM, Brian Duggan wrote:

On Friday, July 28, ToddAndMargo wrote:

I have been fighting with this all day and gave up an hour ago
and just did a system call to curl (this is P5 code):

$CurlStatus = system (
  "curl -L -b $AcceptCookie $ClickHere -o $NewFileName" );


There are also perl 6 bindings to libcurl, e.g.

 http://modules.perl6.org/dist/LibCurl

 From the examples, it looks like ':followlocation' corresponds
to '-L'.

Brian




I like it!  Thank you!



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 06:33 PM, Bennett Todd wrote:

I just googled perl6 libcurl, and got

https://github.com/CurtTilmes/perl6-libcurl

That's definitely where I'd start.



Hi Bennett,

Looks pretty but it is too reduced function.

I need to follow links and to include the
following headers:

   Host
   UserAgent
   Referer
   Cookies

So poop!

Thank you for looking!

:-)

-T


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Bennett Todd
Thank you! I'd have hated for my echo of your knowledge to be the only tip he 
got, and you included a pointer to the option he needed, which I didn't try 
from my phone:-)


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Bennett Todd
As for LWP being a pain, I see it differently,  filling the specs for a web 
client --- many specs --- is a pain. The curl project is trying to wrap a 
blanket around that pain.


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Brian Duggan
On Friday, July 28, ToddAndMargo wrote: 
> I have been fighting with this all day and gave up an hour ago
> and just did a system call to curl (this is P5 code):
> 
> $CurlStatus = system (
>  "curl -L -b $AcceptCookie $ClickHere -o $NewFileName" );

There are also perl 6 bindings to libcurl, e.g.

http://modules.perl6.org/dist/LibCurl

>From the examples, it looks like ':followlocation' corresponds
to '-L'.

Brian


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Bennett Todd
I just googled perl6 libcurl, and got

https://github.com/CurtTilmes/perl6-libcurl

That's definitely where I'd start.


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 12:48 PM, ToddAndMargo wrote:

On 07/28/2017 04:31 AM, Gabor Szabo wrote:
On Fri, Jul 28, 2017 at 9:49 AM, ToddAndMargo  
wrote:

Hi All,

I am trying to convert a p5 program to p6.  What do I use in
place of `LWP::UserAgent`?

I use it for downloading files from the web.  I need to be able
to pass the following to the web page:

 Caller
 Host
 UserAgent
 Referer
 Cookies

This is the p5 code I want to convert:

http://vpaste.net/gtJgj

Any words of wisdom?

Many thanks,
-T


On 07/27/2017 10:30 PM, Gabor Szabo wrote:


LWP::Simple now allows you to set the header of your request.
See my recent article with examples:
http://perl6maven.com/simple-web-client
I hope this helps.

regards
 Gabor

On Fri, Jul 28, 2017 at 7:42 AM, Todd Chester 
wrote:




I see your article.  I do believe this is what I want.

{
   "args": {
 "language": "Perl",
 "math": "19+23=42",
 "name": "Larry Wall"
   },
   "headers": {
 "Connection": "close",
 "Host": "httpbin.org",
 "User-Agent": "LWP::Simple/0.090 Perl6/rakudo"
   },
   "origin": "17.19.208.37",
   "url": "http://httpbin.org/get?name=Larry
Wall=Perl=19%2B23%3D42"
}


Questions:

1) may I leave off the `args` and only include the `headers`?

2) I need an example with headers.  I have no clue what goes
before the first "{"

Many thanks,
-T


I think you quoted the response here and not the request.
What you need I think is the last example on that page.
Something like this:

my $html = LWP::Simple.new.get("http://httpbin.org/headers;, {
 "User-Agent" => "Perl 6 Maven articles",
 "Zone" => "q" }
);


Gabor




Thank you!

how do I save to a file?






And how do I get it to follow links, like `curl -L`?

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread ToddAndMargo

On 07/28/2017 04:31 AM, Gabor Szabo wrote:

On Fri, Jul 28, 2017 at 9:49 AM, ToddAndMargo  wrote:

Hi All,

I am trying to convert a p5 program to p6.  What do I use in
place of `LWP::UserAgent`?

I use it for downloading files from the web.  I need to be able
to pass the following to the web page:

 Caller
 Host
 UserAgent
 Referer
 Cookies

This is the p5 code I want to convert:

http://vpaste.net/gtJgj

Any words of wisdom?

Many thanks,
-T


On 07/27/2017 10:30 PM, Gabor Szabo wrote:


LWP::Simple now allows you to set the header of your request.
See my recent article with examples:
http://perl6maven.com/simple-web-client
I hope this helps.

regards
 Gabor

On Fri, Jul 28, 2017 at 7:42 AM, Todd Chester 
wrote:




I see your article.  I do believe this is what I want.

{
   "args": {
 "language": "Perl",
 "math": "19+23=42",
 "name": "Larry Wall"
   },
   "headers": {
 "Connection": "close",
 "Host": "httpbin.org",
 "User-Agent": "LWP::Simple/0.090 Perl6/rakudo"
   },
   "origin": "17.19.208.37",
   "url": "http://httpbin.org/get?name=Larry
Wall=Perl=19%2B23%3D42"
}


Questions:

1) may I leave off the `args` and only include the `headers`?

2) I need an example with headers.  I have no clue what goes
before the first "{"

Many thanks,
-T


I think you quoted the response here and not the request.
What you need I think is the last example on that page.
Something like this:

my $html = LWP::Simple.new.get("http://httpbin.org/headers;, {
 "User-Agent" => "Perl 6 Maven articles",
 "Zone" => "q" }
);


Gabor




Thank you!

how do I save to a file?



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Need sub for `LWP::UserAgent`

2017-07-28 Thread Gabor Szabo
On Fri, Jul 28, 2017 at 9:49 AM, ToddAndMargo  wrote:
>>> Hi All,
>>>
>>> I am trying to convert a p5 program to p6.  What do I use in
>>> place of `LWP::UserAgent`?
>>>
>>> I use it for downloading files from the web.  I need to be able
>>> to pass the following to the web page:
>>>
>>> Caller
>>> Host
>>> UserAgent
>>> Referer
>>> Cookies
>>>
>>> This is the p5 code I want to convert:
>>>
>>>http://vpaste.net/gtJgj
>>>
>>> Any words of wisdom?
>>>
>>> Many thanks,
>>> -T
>
> On 07/27/2017 10:30 PM, Gabor Szabo wrote:
>>
>> LWP::Simple now allows you to set the header of your request.
>> See my recent article with examples:
>> http://perl6maven.com/simple-web-client
>> I hope this helps.
>>
>> regards
>> Gabor
>>
>> On Fri, Jul 28, 2017 at 7:42 AM, Todd Chester 
>> wrote:
>
>
>
> I see your article.  I do believe this is what I want.
> 
> {
>   "args": {
> "language": "Perl",
> "math": "19+23=42",
> "name": "Larry Wall"
>   },
>   "headers": {
> "Connection": "close",
> "Host": "httpbin.org",
> "User-Agent": "LWP::Simple/0.090 Perl6/rakudo"
>   },
>   "origin": "17.19.208.37",
>   "url": "http://httpbin.org/get?name=Larry
> Wall=Perl=19%2B23%3D42"
> }
> 
>
> Questions:
>
> 1) may I leave off the `args` and only include the `headers`?
>
> 2) I need an example with headers.  I have no clue what goes
>before the first "{"
>
> Many thanks,
> -T

I think you quoted the response here and not the request.
What you need I think is the last example on that page.
Something like this:

my $html = LWP::Simple.new.get("http://httpbin.org/headers;, {
"User-Agent" => "Perl 6 Maven articles",
"Zone" => "q" }
);


Gabor


Re: Need sub for `LWP::UserAgent`

2017-07-27 Thread Gabor Szabo
LWP::Simple now allows you to set the header of your request.
See my recent article with examples: http://perl6maven.com/simple-web-client
I hope this helps.

regards
   Gabor

On Fri, Jul 28, 2017 at 7:42 AM, Todd Chester  wrote:
> Hi All,
>
> I am trying to convert a p5 program to p6.  What do I use in
> place of `LWP::UserAgent`?
>
> I use it for downloading files from the web.  I need to be able
> to pass the following to the web page:
>
>Caller
>Host
>UserAgent
>Referer
>Cookies
>
> This is the p5 code I want to convert:
>
>   http://vpaste.net/gtJgj
>
> Any words of wisdom?
>
> Many thanks,
> -T