How to correctly send binary data over HTTPS POST?

后端 未结 3 818
名媛妹妹
名媛妹妹 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 19:00

    If you don't have to operate in front of web server, you don't have to use HTTPS protocol. From the firewall point of view HTTPS looks like yet another SSL connection and it has no idea what going through. So if the only thing you need is just to pass the data - not to actual web server, use just SSL connection over 443 port.

    So just troubleshoot your SSL connection the problem has nothing to do with HTTP.


    If you want to use HTTP web server and not custom client:

    Two points:

    1. You need to specify Content-Length.
    2. If you are using HTTP/1.1 you need to specify Host header.

    The simplest would be

    POST /url HTTP/1.0
    User-Agent: my custom client v.1
    Content-Type: application/octet-stream
    Content-Length: NNN
    
    Actual Content
    

    Or for HTTP/1.1

    POST /url HTTP/1.1
    Host: www.example.com
    User-Agent: my custom client v.1
    Content-Type: application/octet-stream
    Content-Length: NNN
    
    Actual Content
    

    Note: you can't send infinite data. HTTP protocol requires fixed content-lenght and most of the time web servers would load the data first before passing it to the backend.

    So you will have to transfer data by chunks.

提交回复
热议问题