c# - How to connect but wait to send any header using HttpWebRequest? -


I want to request an https but I want to start the connection first without sending the header, even < Code> GET / Something / HTTP / 1.1 In other words I want to keep the connection ready and send as much as I want.

I would have done this by using a simple TCP / IP, but I am currently running.

I've tried the SendChunked property but it only sends the post to post the data. Edit

  • Send a web request now
  • I have practiced the waiting part and therefore need a detailed explanation on this. is not.

    short answer

    before pre-warming the connection to the HttpWebRequest request Do not show any interface to allow.

    Inspiration

    The reason for this is because the operator has to wait an RTT before sending any data to open a TCP connection and because HTTPS To be able to perform another RTT wait may be the key exchange.

    If you had an RTT from the client's data center of 50ms, then this kind of connection was received from 125 ms (2.5 RTTs for sending requests, but no response) from Pre-Warming for 25 ms (0.5 to send a RTT request, but the response is not received) This is a reduction of 80%.

    Optional Solution

    It is possible to achieve this deficiency without writing the HTTP client or using something other than HTTP Webbate, but in some cases

    normal Technique, to send requests to existing TCP sockets / SSL sessions, reliance on HTP 1.1 leak of connection (otherwise it is called keep-alive).

    Prerequisites: You will need to know the interval of the web server that you are calling. 60 seconds is quite common, but assume, follow it with federal or check settings on the server and load the balance if you have access to it.

    Let's assume that the keep-alive interval is 60 seconds. Create an HttpWebRequest and send a request for a "ping" url (even a non-existent file ... the connection should not stop at a 404 response, unless the server is configured incorrectly) . Restriction at some intervals (for example, every 55 seconds) again send a request again when you want to send a request to the server, you have to wait for a single HTTP webbrand to lock around your When the lock is available to be unavailable, your request will usually go immediately on the existing TCP socket and SSL session. In the rare case that the HTTP webbank is closed, you will have to wait until it is 1 RTT to be released (on average you will wait for 0.5 RTT when it is locked, which is rare, because the possibility that the request is already the wire But the response can already be on the wire).

    This solution can not guarantee that the socket will be kept alive, but it works very well.

    Be careful, but if performance is important, then you should probably be concerned about using HTTP and / or non-HttpWebRequest clients.


    Comments

    Popular posts from this blog

    import - Python ImportError: No module named wmi -

    Editing Python Class in Shell and SQLAlchemy -

    c# - MySQL Parameterized Select Query joining tables issue -