How to correctly send binary data over HTTPS POST?

后端 未结 3 814
名媛妹妹
名媛妹妹 2021-02-07 18:14

I send binary data from client (Debian 6.0.3) to server (Windows Server 2003). To bypass most firewalls I use HTTPS POST. Client and server are implemented usin

3条回答
  •  情歌与酒
    2021-02-07 18:54

    I was misled from the start with this problem. Narrowed it down to surprising details:

    Sending over SSL socket fails if I use Boost.Asio multi-buffers in Boost v.1.48 (the most recent one at this moment). Example:

    // data to send, protocol is [packet size: 4 bytes][packet: packet_size bytes]
    std::vector packet = ...;
    uint32_t packet_size = packet.size();
    // prepare buffers
    boost::array bufs = {{boost::asio::buffer(&packet_size, sizeof(packet_size)), boost::asio::buffer(packet)}};
    // send multi buffers by single call
    boost::asio::async_write(socket, bufs, ...);
    

    Sending separately packet_size and packet in this example works around the problem. I'm far from calling any suspicious behavior as a bug, especially if it's related with Boost libraries. But this one really looks like a bug. Tried on Boost v.1.47 - works fine. Tried with usual TCP socket (not SSL one) - works fine. The same on both Linux and Windows.

    I'm going to find any reports about this problem in Asio mailing list and will report it if nothing found.

提交回复
热议问题