feat: add an extraHeaders option

Similar to the option of the JS client:

```java
opts = new Socket.Options();
opts.extraHeaders = singletonMap("authorization", singletonList("bearer abcd"));
socket = new Socket(opts);
```

Note: the refactor of the options (similar to [1]) will be done in a
future step.

[1] 5f47a50ee5
This commit is contained in:
Damien Arrachequesne
2020-12-11 12:24:07 +01:00
parent 41f89a38b7
commit dfe65e3b3b
5 changed files with 85 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package io.socket.engineio.client;
import java.util.List;
import java.util.Map;
import io.socket.emitter.Emitter;
@@ -43,6 +44,7 @@ public abstract class Transport extends Emitter {
protected ReadyState readyState;
protected WebSocket.Factory webSocketFactory;
protected Call.Factory callFactory;
protected Map<String, List<String>> extraHeaders;
public Transport(Options opts) {
this.path = opts.path;
@@ -55,6 +57,7 @@ public abstract class Transport extends Emitter {
this.socket = opts.socket;
this.webSocketFactory = opts.webSocketFactory;
this.callFactory = opts.callFactory;
this.extraHeaders = opts.extraHeaders;
}
protected Transport onError(String msg, Exception desc) {
@@ -146,5 +149,6 @@ public abstract class Transport extends Emitter {
protected Socket socket;
public WebSocket.Factory webSocketFactory;
public Call.Factory callFactory;
public Map<String, List<String>> extraHeaders;
}
}