Dear Monks,
I have a problem I been struggling with the last week. I am trying to automate the login session to my broadband provider. It is a quite simple form that should be submitted (POSTED) over HTTPS. I have searched and searched for a solution on this problem, but it is still unsolved. Hope your great wisdom are able to help, since I will soon give up.

First the html page to be submitted:
<html> <head> <title>Tele2 Bredband</title> <SCRIPT> function cancel() { if(confirm("\nÄr du säker på att du vill avsluta kontoaktive +ringen?\n\nTryck OK för att avsluta kontoaktiveringen.\nOBS: Ditt kon +to är ännu inte fullständigt registrerat\noch du kommer därför inte a +tt kunna använda ditt\nInternetabonnemang.\n\nTryck Avbryt/Cancel för + att återgå till kontoaktiveringen.")) { window.location="javascript:self.close()"; } } </SCRIPT> </head> <body bgcolor="#FFFFFF" text="#000000" link="#000099" vlink="#800000" +alink="#FFFF00" background="/images/bakgrund.gif"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> </tr> <tr> <td> <img src="/images/head.gif" height="50" width=490 border=0 alt="Kontoa +ktivering"> <table> <tr> <td nowrap width="122" valign=bottom><img src="/images/px.gif" width=1 +00 height=1 border=0 alt="">&#160;</td> <td valign="top" width="468"><br> <font face="arial,helvetica" COLOR="#000099" size="4"><b>LOGGA IN</b>< +/font><br> <font face="Arial,Helvetica" size="-1"> <br> F&ouml;r att b&ouml;rja använda tjänsten m&aring;ste du logga in.<br> Fyll i ditt Anv&auml;ndar-id och l&ouml;senord. </font> <br> <form name=logonForm method="POST" action="https://login1.swipnet.se/l +ogin.php"> <p> <table cellspacing=0 border=0 cellpadding=2> <tr> <td> <font face="Arial,Helvetica" size="-1">Anv&auml;ndar-id:</font><br> <input type="text" name="username" value="xxxxx" size="10" maxlength=" +20"><br> <font face="arial" size="-2">Ex. k-12345</font> </td> <td> <font face="Arial,Helvetica" size="-1">L&ouml;senord:</font><br> <input type="password" name="password" value = "yyyyy" size="11" maxle +ngth="20"><br> <font face="arial" size="-2">Ex. aBc-2h-j</font> </td> </tr> </table> <font face="Arial,Helvetica" size="-1"> Tryck p&aring; knappen <B>&#34;Forts&auml;tt&#34;</B> f&ouml;r att g&a +ring; vidare. </font> <TABLE BORDER=0> <TR> <TD> <input type="submit" STYLE="color: white; background: gray" name="subm +it" value= "Forts&auml;tt"></A> </TD> <TD width=15></TD> <TD> <A HREF="javascript:cancel()"><input type="button" style="color: white +; background: gray" value=" Avsluta " onClick="cancel()"></A> </TD> </TR> </TABLE> </form> </td> </tr> </table> <script language="javascript"> document.logonForm.username.focus(); </script> </td> </tr> </table> </body> </html>

and my perl code:

use HTTP::Request::Common qw(POST); use LWP::UserAgent; use LWP::Debug qw(+); my $ua = LWP::UserAgent->new(); $ua->cookie_jar({}); $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); my $req = POST 'https://login1.swipnet.se/login.php', [username => 'xxxxx', password => 'yyyyy']; print $ua->request($req)->as_string;

The result is the following:
LWP::UserAgent::new: () LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking login1.swipnet.se for cooki +es HTTP::Cookies::add_cookie_header: Checking .swipnet.se for cookies HTTP::Cookies::add_cookie_header: Checking swipnet.se for cookies HTTP::Cookies::add_cookie_header: Checking .se for cookies LWP::UserAgent::send_request: POST https://login1.swipnet.se/login.php LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500 (Internal Server Error) EOF Client-Date: Tue, 24 Feb 2004 23:28:29 GMT

If I do a GET request to the same URL I get the HTML page attached above back, so the HTTPS session is working. It just seems like the POST is not working. I can perform the login with IE in Windows.

I am using perl 5.8.0, with LWP 5.65 on RedHat 9.0.
Please ask if you need more information!

Thanks in advance
/Johan

In reply to LWP HTTPS POST returns 500 EOF by epljsod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.