in reply to LWP HTTPS POST returns 500 EOF

Two suggestions; try them in order and then try them both together:
  1. Do a GET request of this same form before you do a POST. It may be that the GET request sets some required cookies. (such as a session ID)
  2. In the POST, include also the value for the submit button (Fortsätt). I find this unlikely to be the cause, but you never know in what screwy manner these people wrote their php
Actually, the more I think about it, the more I think that (1) is pretty likely the answer. Turning on cookies and then making only one HTTP request is pretty pointless - the other side will see exactly the same traffic from you as if you hadn't enabled cookies. However, if you turn on cookies and then make two requests to the same server, the second request will look different (assuming that the server set a cookie in the first response)

If you're still having problems, one other thing I'd check is that internet explorer is able to process this form after having had all cookies from swipnet.se wiped out and having been started directly at the login page (so that it didn't start somewhere else and get a swipnet session cookie that way).

If it turns out that internet explorer also needs to, say, visit the top page of http://login1.swipnet.se/ and be redirected in order for the login.php form to work, then I'd just replicate the series of pages that explorer visits with a bunch of GET calls to set the appropriate cookies.

Replies are listed 'Best First'.
Re: Re: LWP HTTPS POST returns 500 EOF
by epljsod (Initiate) on Feb 25, 2004 at 22:04 UTC
    Hi,
    thanks for your quick response. Unfortunately, it did not solve my problem.
    1. I first tried to add a GET request (see code below), but it did not help. I do not think cookies is the problem, it was just a desperate attempt from my side. I have tried to clear all cookies in IE (were no from swipnet) and set prompt for cookies but it did not try to set any cookies.
    So I guess the cookie track can be closed.
    2. I tried earlier to add the value for the submit button and tried it once more, but it does not seem to be the problem. When using IE I can change the value of the "Fortsätt" button to anything and it still works.

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

    Any other suggestions ?
    Best regards
    /Johan
      Well, I've looked at your other posts and the only thing I can suggest at this point is to try to match what internet explorer sends absolutely as closely as possible.

      Unfortunately, you're a little limited by LWP in what you can change about your request - it isn't possible to remove the TE header, nor can you easily force LWP to use HTTP/1.0. (I know, your IE isn't doing that, but IE has been known to use HTTP/1.0 when doing SSL through proxy connections)

      One thing you can do is add an "Accept" header with a value of "*/*" to your requests, though if that were really a problem I'd expect your GET to be failing as well.

      I suppose as one final shot, you could try sending in the request with the login information as a "GET" request. Yes, that's completely different from how IE sends it, but you've tried to be nice and identical, and that's gotten you nowhere.

      I've got a small https server here on my local network, and I'm going to see what IE and LWP send differently when presented a form like the one you gave in the top post.

        Ok, I think I await the results from your test towards your local https server to see what you come up with. I think the problem is lurking around inside the header, perhaps the referer or similar field. My problem is that I am unable to debug that information. Please post more information once you are finished with your tests.
        Best regards
        /Johan