-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom configurator for adding headers
- Loading branch information
1 parent
d366e3d
commit f9cec01
Showing
5 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/org/jabref/logic/sharelatex/MyCustomClientEndpointConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jabref.logic.sharelatex; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.websocket.ClientEndpointConfig; | ||
|
||
public class MyCustomClientEndpointConfigurator extends ClientEndpointConfig.Configurator { | ||
|
||
private final String userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0"; | ||
private final String serverOrigin; | ||
|
||
public MyCustomClientEndpointConfigurator(String serverOrigin) { | ||
super(); | ||
this.serverOrigin = serverOrigin; | ||
} | ||
|
||
@Override | ||
public void beforeRequest(Map<String, List<String>> headers) { | ||
|
||
headers.put("User-Agent", Arrays.asList(userAgent)); | ||
headers.put("origin", Arrays.asList(serverOrigin)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters