MobileFirst HTTP Adapter: delete/update back-end cookie value

限于喜欢 提交于 2019-12-12 06:04:38

问题


I'm using WL.Server.invokeHttp(options) several times in my adapter. I need to have different values for a given cookie in different calls.

If I call

WL.Server.invokeHttp({cookies: { 
                        mycookie: 'firstValue'
                        }
                      ...

the back-end gets this header "cookie": "mycookie=firstValue", as expected.

If I later want to make another call with a different cookie value,

WL.Server.invokeHttp({cookies: { 
                        mycookie: 'secondValue'
                        }
                      ...

the back-end gets this header "cookie": "mycookie=firtsValue; mycookie=secondValue".

Is there some way that will let me forget a previous value of the cookie?

Update 2015/02/27

Using the headers option instead of the cookies option, as suggested by @YoelNunez, does not solve it.

  1. My first request gets a "set-cookie": "name=value1; Path=/" response header
  2. My second request sets headers: {cookie: 'name=value2'}
  3. The second requests gets to the server with the following header "cookie": "name=value2, name=value1"

回答1:


Change you invokeHttp to the following

WL.Server.invokeHttp({
    headers: {
        cookie: "mycookie="+myCookieValue
    }
    ...
});

Where myCookieValue is your variable



来源:https://stackoverflow.com/questions/28753979/mobilefirst-http-adapter-delete-update-back-end-cookie-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!