0

I am using HttpSendHttpResponse() with the HTTP_SEND_RESPONSE_FLAG_OPAQUE flag, as proposed by Microsoft (only with 101 response status and response headers prepared using the WebSocketBeginServerHandshake() function), but I receive an ERROR_INVALID_PARAMETER error.

Without this flag, I'm able to establish a WebSocket connection with my server from my browser, but as far as I know I will not be able to use this connection as a WebSocket because HTTP.SYS would try to interpret the connection traffic as HTTP-framed.

Could someone provide me with a link to a working example of HttpSendHttpResponse() usage of the HTTP_SEND_RESPONSE_FLAG_OPAQUE flag?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
AndyX
  • 81
  • 7
  • Asking for tutorials and off-site resources is off-topic for StackOverflow. Please show the code you are having trouble with. A simple web search for `HTTP_SEND_RESPONSE_FLAG_OPAQUE` shows many examples – Remy Lebeau Feb 19 '19 at 17:16
  • I searched, but could not find. I would be very grateful if you give me a link to at least one such example. – AndyX Feb 20 '19 at 06:28
  • @AndyX I have opened [an issue](https://github.com/MicrosoftDocs/feedback/issues/1274) about this you can follow on github. – Rita Han Mar 14 '19 at 07:36

2 Answers2

0

I found the way to use HTTP_SEND_RESPONSE_FLAG_OPAQUE flag correctly: it has to be used in conjunction with HTTP_SEND_RESPONSE_FLAG_MORE_DATA flag. Unfortunately, Microsoft doesn't mention this nuance in their documentation.

AndyX
  • 81
  • 7
0

Based on the document: HttpSendHttpResponse

HttpSendHttpResponse returns ERROR_INVALID_PARAMETER for all other HTTP response types if HTTP_SEND_RESPONSE_FLAG_OPAQUE flag is used.

So it is expected. Just ignore this error temporarily and you can check the receiver part to see if it can receive the correct data.

Rita Han
  • 9,574
  • 1
  • 11
  • 24
  • Thank you, Rita. You're right. Actually it's expected for all other than 101 statuses (based on the same document), but adding HTTP_SEND_RESPONSE_FLAG_MORE_DATA flag helps to omit this error and looks right according to the fact that this connection is going to be used for the future traffic. – AndyX Feb 23 '19 at 10:00