HTTP Send Request Problem 
Author Message
 HTTP Send Request Problem

I have a VC++ Console Application that connects to a Server. I am able
to connect to the webpage. The server requires a login and password. I
am pretty sure what I need to do, however, everytime I do a send
request, with the parameters for the login and password, it seems to
bring me back to the login screen. I am kindof working off the MFC
TEAR Example, with some minor changes.

Here is my code.

int main(int argc, char* argv[])
{
        DWORD dwRet = 0;
        CHttpConnection* pServer = NULL;
        CHttpFile* pFile = NULL;

//      CString strHeaders = _T("Content-Type: application/x-www-form-    
                          urlencoded");
        CString strHeaders = _T("Accept: ENCTYPE: multipart/form-data");
//      TCHAR szHeaders[] = _T("Accept: */*\r\nContent-Type:
application/x-www-                              
form-urlencoded\r\n");

        CString strFormData = _T("value=login&key=password&clcode=client
code");

        CInternetSession session("Tear");
        CHttpConnection* pConnection =
session.GetHttpConnection(_T("ecf.nynb.uscourts.gov"));
        pFile = pConnection->OpenRequest("POST","/cgi-bin/login.pl");
        pFile->AddRequestHeaders(strHeaders);
        pFile->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData,
strFormData.GetLength());
        //pFile->SendRequest(NULL, 0, "value=mt0167&key=4tooqui4&clcode=mis",
30);

        pFile->QueryInfoStatusCode(dwRet);

        TCHAR sz[1024];
        while (pFile->ReadString(sz, 1023))
        {
                StripTags(sz);
                cout << sz;
        }

Quote:
}

Im not sure if I am sending the correct parameters for the CGI script
to authenticate the login. Here is the source for the login page after
I do a view Source.

<HTML><HEAD><TITLE>CM/ECF LIVE DATABASE - login</TITLE></HEAD><BODY
BGCOLOR=LIGHTBLUE TEXT=00000 onLoad='SetFocus()'><SCRIPT
LANGUAGE="JavaScript">
                var IsForm = false;
                var FirstField;
                function SetFocus() {
                        if(IsForm) {
                                if(FirstField) {
                                        var ind = FirstField.indexOf('document.',0);
                                        if(ind == 0)
                                        {
                                                eval(FirstField);
                                        }
                                        else
                                        {
                                                var Code = "document.forms[0]."+FirstField+".focus();";
                                                eval(Code);
                                        }
                                } else {
                                        var Cnt = 0;                            
                                        while(document.forms[0].elements[Cnt] != null) {
                                                if(document.forms[0].elements[Cnt].type != "hidden") {
                                                        document.forms[0].elements[Cnt].focus();
                                                        break;
                                                }
                                                Cnt += 1;
                                        }
                                }
                        }
                        return(true);
                }
                </SCRIPT>
 <FORM ENCTYPE='multipart/form-data' method=POST
action="/cgi-bin/login.pl?107613127631253-L_916_0-1" >
<!-ShowPage(login.htm)-> <!-- rcsid="$Header:
/ecf/bankruptcy/html/login.htm,v 2.8 2002-04-10 10:15:27-04 dwilharm
Exp $" -->

<SCRIPT LANGUAGE="JavaScript">

function onLoad()
{   // on load reset password field to null
        document.cookie="KEY=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT";
        document.cookie="PacerUser=; path=/; domain=.uscourts.gov;
expires=Thu, 01-Jan-70 00:00:01 GMT";
    document.forms[0].key.value = "";
        if (document.forms[0].login.value) {
                document.forms[0].key.focus();
        } else {
        document.forms[0].login.focus();
        }
  return(true);

Quote:
}

</SCRIPT>

<BASEFONF SIZE=2>
<FONT FACE="arial,helvetica">
<FONT COLOR="#0000cc" SIZE=5>

<B>ECF/PACER Login</B>

</FONT>
<br>
<br>
<TABLE WIDTH=600 border=0>
  <TR>
    <TD>
        <P><FONT FACE="arial,helvetica"><B>Notice</B></FONT><br>
        <FONT SIZE=-1>
    This is a <B>Restricted Web Site</B> for Official Court Business
only. Unauthorized entry is prohibited and subject to prosecution
under Title 18 of the U.S. Code. All activities and access attempts
are logged.
        </FONT>
<BR><BR>
        <P>

    <P><FONT FACE="arial,helvetica"><B>Instructions</B></FONT><br>
        <FONT SIZE=-1>
    Enter your ECF login and password for electronic filing
capabilities.  If you do not need filing capabilities, enter your
PACER login and password.  If you do not have a PACER login, contact
the PACER Service Center to establish an account.  You may register
online at <a HREF=" http://www.*-*-*.com/ "> http://www.*-*-*.com/ </a>
or call the PACER Service Center at (800) 676-6856 or (210)
301-6440.<P>An access fee of $.07 per page, as approved by the
Judicial Conference of the United States at its September 1998
session, will be assessed for access to this service.  All inquiries
will be charged to your PACER login that is kept on file.  If you do
not need filing capabilities, enter your PACER login and password. The
Client code is provided to the PACER user as a means of tracking
transactions by client.  This code can be up to thirty two
alphanumeric characters long.
        </FONT>

        </TD>
  </TR>
</TABLE>
<BR>
<TABLE BORDER=0 CELLPADDING=6 CELLSPACING=0>
  <TR>
    <TD BGCOLOR="#cccccc">
        <FONT FACE="arial,helvetica" SIZE=2>
    <B>Authentication</B>
    </FONT>
<TABLE BGCOLOR="#ffffcc" BORDER=0 CELLPADDING=4 CELLSPACING=0>
  <TR>
    <TD>
          <FONT FACE="arial,helvetica" SIZE=2>
      Login:
          </FONT>
    </TD>
    <TD>
          <input type=text size=20 maxlength=256 name="login" value=  >
    </TD>
  </TR>
  <TR>
    <TD>
          <FONT FACE="arial,helvetica" SIZE=2>
      Password:
          </FONT>
    </TD>
    <TD>
          <input type=password size=8 maxlength=8 name="key">
    </TD>
  </TR>

  <TR>
  <TD>
    <FONT FACE="arial,helvetica" SIZE=2>
     client code:
    </FONT>
  </TD>
  <TD>
    <input type=text size=32 maxlength=32 name="clcode">
  </TD>
  </TR>

</TABLE>
</TD>
</TR>
</TABLE>
<P>
</FONT>
<SCRIPT LANGUAGE="JavaScript">
onLoad();
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
                var timerId;
                var BeenHere = 0;
                IsForm  = true;
                function empty(s) {
                        var whitespace = " \t\n\r";
                        if(s == null || s.length == 0) {
                                return(true);
                        }
                    // Is s only whitespace characters?
                    for (var i = 0; i < s.length; i++) {
                        var c = s.charAt(i);
                         if (whitespace.indexOf(c) == -1) return false;
                    }
                        return(true);
                }
                function ClearTimer() {
                        BeenHere = 0;
                        clearTimeout(timerId);
                        return(true);
                }
                var FormId = 0;
                function ProcessForm() {
                        if(BeenHere == 1) {
                                alert("Submission already made, please wait for response from
server");
                                return(false);
                        }
                        BeenHere = 1;
                        timerId=setTimeout("ClearTimer()",5000);
document.forms[FormId].submit();return true

Quote:
}</SCRIPT>

<TABLE> <TD><INPUT NAME="button1" Value=Login TYPE="button"
ONCLICK="ProcessForm()" >
<TD> <TD><TD> <INPUT NAME="reset" TYPE="RESET" VALUE="Clear">
<TR></TABLE ></FORM><I>CM/ECF has been tested and works correctly with
Netscape 4.6x, Netscape 4.7x and Internet Explorer
5.5.</I></BODY></HTML>

Every time I run the App It takes me back to the login page. I am
stuck. Could anyone please help? Thanks in Advance. Feel free to email
me.



Sun, 18 Dec 2005 02:28:02 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. problem sending http request.

2. Sending/Receiving HTTP requests

3. Missing % characters when Sending HTTP requests with WinInet

4. Sending HTTP request?

5. Sending FORM POST HTTP Request

6. how to send a http request by socket,thanks

7. Send HTTP request

8. HELP: Intercepting HTTP Request, Showing Login Page, and Continuing with Original Request

9. problem posting http request through StreamWriter

10. Problem with file transfer through HTTP request

11. TCP (HTTP) problems... XML file getting over HTTP

12. XML HTTP request

 

 
Powered by phpBB® Forum Software