#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    4
    Rep Power
    0

    Strange behavior of idHTTP POST over SSL


    Hello, I have such a really strange problem with idHTTP.Post() function when using it on HTTPS site. For example, I'm sending form input data to the https://url/action.asp. The query is correct, because on my computer everything works fine. Script gets that data as it is provided by my program and replies "Submit accepted". But on another computer, script gets that data, and returns page with form, which I'm trying to submit with all filled inputs with params that I'm sending. And somehow it doesn't understands that I'm simulating Submit event. I've tried this program with 5 differente computer with different operating systems (WinXP and Win7), on two of them program worked fine, but on others hapens that strange thing. Why that's happening? Is there any other independecies instead of SSL libraries? Maybe query string somehow get's corrupted, but then why all form inputs are filled with params that were sent just Submit wasn't triggered?

    Now in short words what we have:

    *Delphi 7 with Indy 10;
    *Program runs without any errors or exceptions;
    *SSL libraries are loaded (HTTPS works);
    *Strange error on some computers (Submit doesn't works, and that is main problem);

    Sorry for my bad English.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    What do any error messages and logs that are created contain?
    Its a bit unclear to me, are all five computers sending the request to the same server?
    Is there anything consistent about the computer and O/S combinations that work or do not work?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    4
    Rep Power
    0
    Program by itself does'nt create any error, because there is no errors. It seems that request gets somehow corrupted, but the data that was sending gets parsed successfully by script on server side it just does'nt accepts it, like there is something missing. But script doesn't generates any error also...

    All five computers were tested with that same program. There was no change in code. Compiled and builded version. And there is no difference in operating systems because I'm running W7 and program works fine for me, but on another computer with w7 it doesn't works as it suppose to be.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    4
    Rep Power
    0
    Here is the code

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    http.IOHandler := ssl;
    DownloadedInfo := TStringList.Create;
    Downloadedinfo.Text := http.Get('https://url/login.asp?username=' + Edit1.Text + '&password=' + Edit2.Text);
    lookfor := '?UserName=' + Edit1.Text;
    SessionID := Copy(DownloadedInfo.text, POS(lookfor, Downloadedinfo.Text)+length(lookfor)+4, 43);
    data := TStringList.Create;
    Response := TStringStream.Create('');
    data.Clear;
    data.Text := 'Submit=Submit&username='+ Edit1.Text +'&CD=' + SessionID +' &submitting=1&venue=Classifieds&adtype=Classifieds&viewableat=' + Edit3.Text + '&approvedtext=';
    http.IOHandler := ssl;
    HTTP.Request.ContentType := 'application/x-www-form-urlencoded';
    try
    http.post('https://url/submit.asp', data, response);
    lookfor := 'Submitted';
    if POS(lookfor, response.DataString) <> 0 then
    begin
    ShowMessage('Action success'); //if request processed without errors
    end;
    lookfor := 'Failed';
    if POS(lookfor, response.DataString) <> 0 then
    begin
    ShowMessage('Action error'); //if there is some errors, like empty fields
    end;
    except
       on E : Exception do ShowMessage(E.Message);
      end;
    end;
    As you can see, I can handle both - success and error actions. But in this case - I've got either "Success", either nothing. Just nothing. Server returns that same form, which I'm trying to submit, but with already filled fields (that means that the data was posted but for unknown reason not accepted) and if there was incorrect value, in html code that input gets marked with "Failed" tag, but there is no "Failed" tags. None of component returns any error (http.responsecode returns 200 allways) or exceptions. I'm guessing that there is something messed up with idHTTP and SSL. Because I can't explain that whats happening. On my computer, where this program works fine, if I'm posting all values - script shows "Submited", if I leave any empty field (instead of approvedtext - it's not necessary) - script returns "Failed". On computers where this program can't do that post action - script just returns pre-filled form, as mentioned before, without any "Submited" or "Failed" tags.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    I don't know enough about the specific components you are using to offer clear advice.

    I am still not clear about whether all the computers are talking to a single unique server.
    Is there no way you can turn on additional logging on the server?

    If this is your real code then there are a number of general things:
    1. You are creating lots of objects without ever freeing them.

    2. From a point of ignorance I don't understand how this line works
    http.post('https://url/submit.asp', data, response);
    Is something in your component translating the TStringStream into something HTTP protocol understands?

    Sorry I can not help beyond this.

    Clive
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    4
    Rep Power
    0
    Yes, server is one for all users.
    I cannot view any logs, because server is not mine.

    About freeing objects - well, thats not the main problem yet.

    TStringStream is used for response from server, the data I'm sending to it is placed in TStringList and encoded as www-form-data.

    Anyway, the question remains - why it works on some computers, but does not on others...

IMN logo majestic logo threadwatch logo seochat tools logo