Skip to content

Commit

Permalink
Add information about HTTP polling
Browse files Browse the repository at this point in the history
  • Loading branch information
ben221199 committed Mar 21, 2024
1 parent e13def4 commit e280771
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions bip-0040.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,25 @@ Stratum over a TCP connection with SSL/TLS. Just the same as normal TCP, but wit
===HTTP===

Stratum over an HTTP connection.
Stratum over an HTTP connection. When communicating over HTTP, there 2 possible options: polling and pushing. In both cases, the request and response have a <code>Content-Type</code> header with the value <code>application/stratum</code>. Like in the TCP transport, the messages have to end with a line-feed (\n). It is possible to send more messages in one HTTP request or response. It could be possible that a request or response also has a <code>Content-MD5</code> header, so it is possible for the receiver to detect any modifications to the content. It is up to clients and servers how to handle upon a mismatch. A suggestion for a client would be to retry the command. A suggestion for a server would be to return a 400 error (or return a 200 error with a JSON-RPC error message).

* Default port: <code>8081</code>
* Letter: <code>h</code>
====Session====

Because it is not sure if an HTTP connection will stay open, it is highly possible that messages will be sent over multiple connections. To keep track of the same "session", cookies are used. If a client sends a request with a cookie, the servers knows exactly which session is used and which notifications to send.

====HTTP Poll====

When polling, an empty HTTP POST request is sent with <code>application/stratum</code> in the <code>Content-Type</code> header.

If no error occurred, the server will respond with a 200 status code and with <code>application/stratum</code> in the <code>Content-Type</code> header. If there are one or more notifications, the body will contain those notifications. Else, the body will be empty.

====HTTP Push====

TODO

===HTTP over SSL/TLS===

Stratum over an HTTP connection with SSL/TLS. Just the same as normal HTTP, but with SSL/TLS enabled.
Expand All @@ -79,17 +93,19 @@ Stratum over a WebSocket connection. Every JSON-RPC message (including batch mes
* Default port: <code>8083</code><ref name="extended">This is extended specification information of the Stratum wire protocol to make it more complete. This information will not be found in any code or specification before this BIP.</ref>
* Letter: <code>w</code><ref name="extended"/>
====Subprotocol====
====Subprotocol<ref name="extended"/>====

In a WebSocket upgrade request, it is possible to use the <code>Sec-WebSocket-Protocol</code> header to let the WebSocket server know which subprotocol is desired to send over the connection. For Stratum, the value <code>stratum</code> is registered. The use of this header is optional. If the server supports the use of this subprotocol too, it will let the client know by sending a <code>Sec-WebSocket-Protocol</code> header back. If the server doesn't send a subprotocol back, the connection will continue without using one. Use of this feature is fully backwards compatible.

====Example====

<code>
new WebSocket('ws://stratum.example.com:8083',['stratum']); // Open WebSocket with using a subprotocol
<pre>
// Open WebSocket with using a subprotocol
new WebSocket('ws://stratum.example.com:8083',['stratum']);

new WebSocket('ws://stratum.example.com:8083'); // Open WebSocket without using a subprotocol
</code>
// Open WebSocket without using a subprotocol
new WebSocket('ws://stratum.example.com:8083');
</pre>

===WebSocket over SSL/TLS===

Expand Down

0 comments on commit e280771

Please sign in to comment.