简体   繁体   English

忽略Groovy HTTPBuilder中的cookie

[英]ignoring cookies in Groovy HTTPBuilder

I'm getting a lot of these warning messages on a REST client call that doesn't require cookies: 在不需要cookie的REST客户端调用中,我收到了很多这些警告消息:

[http-bio-8080-exec-10] WARN  protocol.ResponseProcessCookies  - Cookie rejected: "[version: 1][name: mzf_in][value: 990108][domain: .xxxx.com][path: /asdf][expiry: null]". Domain attribute ".xxxx.com" violates RFC 2109: host minus domain may not contain any dots
[http-bio-8080-exec-10] WARN  protocol.ResponseProcessCookies  - Cookie rejected: "[version: 0][name: mzf_dr][value: 0][domain: .xxxx.com][path: /asdf][expiry: Wed Dec 31 21:00:00 ART 1969]". Illegal path attribute "/asdf". Path of origin: "/xyz"

I want to disable the cookie processing in the Groovy HTTPBuilder calls I'm using. 我想在正在使用的Groovy HTTPBuilder调用中禁用cookie处理。 Googling I found that there is supposed to be a way to "set the policy to ignore cookies" ( http://lists.canoo.com/pipermail/webtest/2006q2/005902.html ) in the "httpclient params". 谷歌搜索,我发现应该有一种方法可以在“ httpclient params”中“将策略设置为忽略cookie”( http://lists.canoo.com/pipermail/webtest/2006q2/005902.html )。 Tried adding that to my Groovy/Grails code but couldn't make it work. 尝试将其添加到我的Groovy / Grails代码中,但无法使其正常工作。 Didnt find any information related to this in the official HTTPBuilder site. 在官方的HTTPBuilder站点中找不到与此相关的任何信息。 Anybody has configured the IGNORE_COOKIES option in Groovy/Grails HTTPBuilder? 有人在Groovy / Grails HTTPBuilder中配置了IGNORE_COOKIES选项吗? Can somebody provide a more specific example? 有人可以提供一个更具体的例子吗?

Some time ago I did with the following piece of code: 前一段时间,我使用以下代码:

import static org.apache.http.client.params.ClientPNames.COOKIE_POLICY
import static org.apache.http.client.params.CookiePolicy.IGNORE_COOKIES

def http = new AsyncHTTPBuilder(
   poolSize: conf.getInt('client.poolSize'),
   uri: conf.getString('client.url'),
   contentType: JSON
)
http.client.params.setParameter(COOKIE_POLICY, IGNORE_COOKIES)
http.client.params.setParameter('http.connection-manager.max-total', 50)
http.client.params.setParameter('http.connection-manager.max-per-host', 50);
http

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM