Is the IBM Worklight HTTP adapter sending / sending User-Agent header submissions?

Typically, IBM Worklight HTTP adapters (in 6.1) send a default User-Agent header when calling an internal service using WL.Server.invokeHttp? What is the value? Assuming the answer is no, can we add one?

0
source share
2 answers

In the adapter, you can get the user agent sent by the client as follows:

var clientRequest = WL.Server.getClientRequest();
var userAgent = clientRequest.getHeader("User-Agent");

If you want to pass this header along with the backend service:

var input = {
    method :'get',
    path : 'your/path',
    headers: {
        "User-Agent" : userAgent,
    }
};

var result=WL.Server.invokeHttp(input);
+3
source

, , Wireshark. , User-Agent. HTTP- Apache.

, . WL.Server.invokeHttp:

Parameters:  
options - The invokeHttp function accepts the following JSON block of parameters:  
...  
...  
...  
headers. Optional. Defines the headers for the HTTP request.

:

var input = {
        method : 'get',
        headers: {foo: 'bar'},
        path : '/mypath'
};  
return WL.Server.invokeHttp(input);

, . .
. ( google ): HTTP-: UserAgent

+1

All Articles