Jersey Equivalent to HttpUrlConnection

放肆的年华 提交于 2020-04-30 10:19:13

问题


So I am trying to add a cookie to a connection. In HTTPUrlConnection, I do the following:

HttpURLConnection con;
String cookieString = null;
con = ((HttpURLConnection) new URL(appUrl).openConnection());
String cookieString = formatCookies("session", userCredential);
con.setRequestProperty("Cookie", cookieString);
...

I want to do the same in Jersey. So far I have the following:

WebTarget wt = client.target(appUrl).path(path);
wt.queryParam(..., ...)
    .request(...)
    .cookie("session", userCredential)
    .get(InputStream.class);

Is this the correct way to go about this?

来源:https://stackoverflow.com/questions/60512611/jersey-equivalent-to-httpurlconnection

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