Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8237607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:31:29+00:00 2026-06-07T19:31:29+00:00

I have a problem with sending POST via https. In the code snippet above,

  • 0

I have a problem with sending POST via https. In the code snippet above, the first part (commented) works well. Next part does not: it doesn’t send any request.
What do I need to fix it?

P.s Perhaps the problem arises from the fact that my Lib boost does not support HTTPS.

    #include "stdafx.h"
    #include <iostream>
    #include <boost/asio.hpp>
    #include <conio.h>
    #include <stdio.h>
    #include <fstream>

    char buffer [9999999];

    int main()
    {
        boost::asio::ip::tcp::iostream stream;
        stream.expires_from_now(boost::posix_time::seconds(60));
        stream.connect("www.mail.ru","http");
        //stream << "GET / HTTP/1.1\r\n";
        //stream << "Host mail.ru\r\n";
        //stream << "User-Agent   Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11\r\n";
        //stream << "Accept   text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" ;
        //stream << "Accept-Encoding  gzip,deflate,sdch\r\n";
        //stream << "Accept-Language  en-US,en;q=0.8\r\n";
        //stream <<"Accept-Charset    ISO-8859-1,utf-8;q=0.7,*;q=0.3\r\n";
        //stream << "Cookie   \r\n\r\n";

    stream << "POST https://auth.mail.ru/cgi-bin/auth HTTP/1.1\r\n";
    stream << "Host: auth.mail.ru\r\n";
    stream << "User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1\r\n";
    stream << "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
    stream << "Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3\r\n";
    stream << "Accept-Encoding: gzip, deflate\r\n";
    stream << "Connection: keep-alive\r\n";
    stream << "Referer: http://mail.ru/\r\n";
    stream << "X-MailRuSputnik: generic\r\n";
    stream << "Content-Type: application/x-www-form-urlencoded\r\n";
    stream << "Content-Length: 59\r\n";

    stream << "Domain=mail.ru&Login=(login)&Password=(password)&level=0\r\n";

        stream.flush();
        using namespace std ;
     // cout << stream.rdbuf();
        ofstream f("output.txt" /*| ios::bin*/);
        f << stream.rdbuf();
        f.close();
        system("pause");
        return 0 ;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:31:32+00:00Added an answer on June 7, 2026 at 7:31 pm

    There are several problems with your code.

    1) Your POST line is specifying the full URL when it should be specifying just the host-relative path instead. Do not specify the URL scheme or hostname in that line. That is only needed when connecting to proxies.

    stream << "POST /cgi-bin/auth HTTP/1.1\r\n";
    

    2) HTTP headers are terminated by two sequential CRLF pairs, but your code is only sending one CRLF pair between the Content-Length header and the body data, and your body data only ends with one CRLF pair (which you do not need), so there is nothing to tell the server when the HTTP request has finished being sent.

    stream << "Content-Length: 59\r\n"; 
    stream << "\r\n"; // <-- add this
    

    3) The value of your Content-Length header is 59, but the length of the body data you showed is 58 instead. That will cause the server to try to read more bytes than you are actually send, preventing a response from being sent (unless the server implements a receive timeout and can then send back an error response). I suggest you put the body data into a std::string and then use its length() method to fill in the correct Content-Length value dynamically instead of hard-coding it.

    std::string content = "Domain=mail.ru&Login=(login)&Password=(password)&level=0";
    ...
    stream << "Content-Length: " << content.length() << "\r\n";
    stream << "\r\n";
    
    stream << content;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem sending POST request with VB6. The code below works properly
i have created custom query which i am sending via POST ajax but problem
I have a problem when trying to send a POST request. The sending method
I have the following problem. A web service is sending a JSON POST request
I have a problem when sending a form via email using the PHP Mail
I have a problem with sending POST http request. It stops on (HttpWebResponse)request.GetResponse() and
Hi I have a problem in sending data from php to pdf. I think
I have a problem when I want to sending data using byte format in
I have a little problem, I'm making project and I'm sending data from client
I have a test script to receive an xml file via http post and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.