简体   繁体   中英

How to add cookies with HttpOnly and Secure flags in Spring Webflux webclient?

Current to set the cookies in SpringWebFlux web client, I am manually adding cookies with the equal sign like name1=value;name2=value;name3-value and adding it to the header with Cookie key.

webclient.get().header("Cookie",name1=value;name2=value;name3-value);

But I don't know how to add HttpOnly or Secure flag for these cookies being added.Please let me know how to add these flags while making REST calls to the Https URL using spring webclient? I couldn't find a way to add these flags. Adding these flags mandatory if the connection is over HTTPS?

I am manually adding cookies with the equal sign like name1=value;name2=value;name3-value and adding it to the header with Cookie key.

This is a very odd way of doing things - you can add cookies directly with WebClient by using webclient.get().cookie() .

But I don't know how to add HttpOnly or Secure flag for these cookies being added.

You can't, and you don't need to - these are flags sent by the server to the client to detail restrictions that the browser should enforce in handling these cookies. It therefore makes no sense to set those flags when sending the cookies to the server - there's no useful behaviour the server would be able to take based on those flags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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