I am trying to do a post using the following code, however on the server
side I am seeing -1 always
for content length, however this does not happen when I do a non ssl based
post using the
same POST header built below. Any help will be appreciated.

        SSL_library_init(); 
        .....
        ....
        m_pSSL_CTX=SSL_CTX_new(SSLv23_client_method());
        ....
        ...
        m_pSSL = SSL_new(m_pSSL_CTX);
        ....
        ...
         SSL_set_connect_state(m_pSSL);
       
        m_pBIOConnection = BIO_new_connect("ecomm01:443");
        ..
        
        SSL_set_bio(m_pSSL, m_pBIOConnection , m_pBIOConnection);
        ..      
        nRC=SSL_do_handshake(m_pSSL);
        ..
        

        //Until here everything looks fine based on my error checking and
return values, I can also print the
        //certificate details received from the server
        

        sprintf(szBuf,
          "POST %s HTTP/1.0\r\nContent-Type: %sContent-Length: %d\r\n",
m_szURL, "text/html\r\n\r\n", nBytesToWrite);
        nHeaderSize = strlen(szBuf);
        nBytesWritten = sendData(szBuf, nHeaderSize);


        int SSLSocket::sendData(char *pszBuf, int nBytesToSend)
        {
        int nBytesSent; // bytes sent at each loop iteration
        int nTotalBytesSent = 0; // total bytes sent
        int nOffset = 0;

        while(1) // Keep sending until all done
        {       
                 nBytesSent = SSL_write(m_pSSL, &(pszBuf[nOffset]),
nBytesToSend);

                         if (nBytesSent < 1) 
                          break;

                 nOffset += nBytesSent;
                 nTotalBytesSent += nBytesSent;
                nBytesToSend -= nBytesSent;

                if (nBytesToSend < 1) // Nothing else left to send
         break;
         }

        printf("The total number of bytes sent :---%d\n", nTotalBytesSent);
        return nTotalBytesSent;
        }

Rgds
Lakshmi
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to