need some visual clarity/implimentation LWP help

Discussion in 'Perl Misc' started by buildmorelines, Oct 8, 2004.

  1. I would like to know how to merge the cookies line into creation of
    request variable/object?. The code works fine, but for visual clarity
    it would be nice to merge the cookies line into some other line if
    possible.(I love Perl because it still has a good old thing called
    procedural programing, OO stuff is chinese to me).

    my $ua = new LWP::UserAgent;
    my $request = HTTP::Request->new('GET', $my_url);
    $request->header('Cookie' => 'foo_likes_it=hi');
    my $response = $ua->request($request);
    print $response->content;

    Also, less importantly (remember TMTOWTDI), did I do the right thing
    by adding a static cookies header to the HTTP request? or should the
    professional way be through the cookie_jar of LWP::UserAgent, and then
    to HTTP::Cookies, or play with HTTP::Headers?

    The cookie is always static, and never needs to be changed. There is
    no need to "save" or "capture" any cookies from the server.
    buildmorelines, Oct 8, 2004
    #1
    1. Advertising

  2. buildmorelines <> wrote:

    > The code works fine, but for visual clarity
    > it would be nice to merge the cookies line into some other line if
    > possible.



    One way to do that would be to remove the newline character
    between the two lines in question. :)


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Oct 8, 2004
    #2
    1. Advertising

  3. buildmorelines

    Ben Morrow Guest

    Quoth (buildmorelines):
    > I would like to know how to merge the cookies line into creation of
    > request variable/object?. The code works fine, but for visual clarity
    > it would be nice to merge the cookies line into some other line if
    > possible.(I love Perl because it still has a good old thing called
    > procedural programing, OO stuff is chinese to me).
    >
    > my $ua = new LWP::UserAgent;
    > my $request = HTTP::Request->new('GET', $my_url);
    > $request->header('Cookie' => 'foo_likes_it=hi');
    > my $response = $ua->request($request);
    > print $response->content;


    Uuuuuh....

    (my $req = H:R->new())->header();

    > Also, less importantly (remember TMTOWTDI), did I do the right thing
    > by adding a static cookies header to the HTTP request? or should the
    > professional way be through the cookie_jar of LWP::UserAgent, and then
    > to HTTP::Cookies, or play with HTTP::Headers?


    I would *never* write a cookies header by hand. I would use
    HTTP::Cookies->set_cookie and HTTP::Cookies->add_cookie_header.

    [I would also attempt to learn how to type 'cookie' without it coming
    out as 'cooiek' ;) ]

    Ben

    --
    "If a book is worth reading when you are six, *
    it is worth reading when you are sixty." - C.S.Lewis
    Ben Morrow, Oct 9, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tj
    Replies:
    4
    Views:
    12,724
  2. Stevie_mac
    Replies:
    8
    Views:
    368
    Scott David Daniels
    Apr 11, 2004
  3. Replies:
    4
    Views:
    2,370
  4. Replies:
    60
    Views:
    1,229
    David Thompson
    Feb 12, 2009
  5. Jaddu

    log4net implimentation in a DLL ..???

    Jaddu, Jun 11, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    124
    Jaddu
    Jun 11, 2007
Loading...

Share This Page