阻止HttpURLConnection发送cookie

时间:2017-03-01 03:35:59

标签: java java-ee

我有以下代码:

URL uri = new URL(my_service_url);
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("content-type", "application/x-www-form-url-encoded");
connection.connect();

// I process request here

大部分时间都可以正常运行,只是有时请求有一些我不会设置的标题,特别是一些Cookie,如:" Cookie:JSESSIONID = XXXX&# 34 ;.在我的情况下,这会导致问题,因此我的请求有时会失败。

如何确保我的请求不会发送我未明确设置的其他Cookie?

1 个答案:

答案 0 :(得分:0)

您可以通过将其明确设置为空来避免发送Cookie

select id, min(date) as min_latest_incorrect_date
from (select t.*,
             max(case when state = 'Correct' then date end) over (partition by id) as max_date_correct
      from t
     ) t
where (date > max_date_correct or max_date_correct is null) and
      state = 'Incorrect'
group by id