Hi Harish,
You could probably have continued down the path with the other library
you were using (and not have to manually construct the POST request).
HTTPS is essentially HTTP encapsulated in SSL-- so, for your purposes,
both libraries should do the same thing. But, if you're able to get
it working this way-- thats good too :)
As for the problems here-- I believe there are several issues:
* A space following the content-length number
* Only a single \r\n pair after the content length. There should be 2
pairs separating the headers from the body
* For HTTP/1.1, a 'Host: www.google.com' header is required. You
could change to HTTP/1.0 and remove this requirement
Everything else looks good -- let me know how these changes work out.
Thanks,
-Ryan
On Mar 28, 5:05 am, "Harish Kumar Dixit" <[EMAIL PROTECTED]>
wrote:
> hello friends i i m trying to access google calendar information
> programatically. I m using SSL for making connection.
>
> I m uisng follwoing code:
>
> WORD wVersionRequested;
> WSADATA wsaData;
> int err;
>
> wVersionRequested = MAKEWORD( 2, 2 );
>
> err = WSAStartup( wVersionRequested, &wsaData );
>
> hostent* pHost = (hostent*)gethostbyname("www.google.com");
>
> char* pIPAddr = inet_ntoa(*(reinterpret_cast<in_addr*>(pHost-
>
> >h_addr))) ;
>
> SSL_load_error_strings(); /* readable error
> messages
> */
> int nRet = SSL_library_init(); /*
> initialize
> library */
>
> SSL_load_error_strings();
> SSLeay_add_all_algorithms ();
> SSLeay_add_ssl_algorithms ();
>
> SSL_METHOD *meth = NULL;
> SSL_CTX *ssl_ctx = NULL;
> meth = SSLv2_client_method();
> ssl_ctx = SSL_CTX_new(meth);
> SSL * ssl = NULL;
> ssl = SSL_new(ssl_ctx);
>
> SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
>
> struct sockaddr_in gsin;
> gsin.sin_family = AF_INET;
> gsin.sin_addr.s_addr = inet_addr((const char*)pIPAddr);
> gsin.sin_port = htons(443);
>
> nRet = connect(sock,(SOCKADDR*) &gsin, sizeof(sockaddr));
> DWORD dw = GetLastError();
>
> nRet = SSL_set_fd(ssl, sock);
> nRet = SSL_connect(ssl);
> CURLEncode url_encode;
>
> char Data[] = "POSThttp://www.google.com/accounts/ClientLogin
> HTTP/
> 1.1 \r\n Content-type: application/x-www-form-urlencoded \r\n
> Content-
> Length:1357 \r\n
> accountType=HOSTED_OR_GOOGLE&[EMAIL
> PROTECTED]&Passwd=harishiit&service=cl&source=DoMo-
> TestDLL-1.0.0.1 \r\n\r\n";
> nRet = SSL_write(ssl, Data, strlen(Data)); //sending HTTP
> POST
>
> nRet = SSL_state(ssl);
>
> char buf[1000];
> int nret;
> CString m_out = L"";
> while(nret = SSL_read(ssl, buf, 999))
> {
> buf[nret] = 0;
> CString str(buf);
> m_out += str;
> }
>
> AfxMessageBox(m_out);
> if ( LOBYTE( wsaData.wVersion ) != 2 ||
> HIBYTE( wsaData.wVersion ) != 2 )
> {
> WSACleanup( );
> }
>
> after reading data i should get some Auth token but in response
> i m getting following message
>
> Google Error:
> Length Required
> "POST requests require a Content-length header."
>
> i think i m doing some mistake in following url forming line.....
>
> char Data[] = "POSThttp://www.google.com/accounts/ClientLoginHTTP/
> 1.1 \r\n Content-type: application/x-www-form-urlencoded \r\n
> Content-
> Length:1357 \r\n
> accountType=HOSTED_OR_GOOGLE&[EMAIL
> PROTECTED]&Passwd=harishiit&service=cl&source=DoMo-
> TestDLL-1.0.0.1 \r\n\r\n";
>
> If anyone have some idea then plz help me.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---