简体   繁体   中英

Jersey client - set IP address

I have Jersey REST client:

Client client = Client.create();
WebResource webResource = client.resource(resource);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, requestEntity);

Server uses @Context HttpServletRequest httpServletRequest; to read sender IP httpServletRequest.getRemoteAddr() . Is there any way to set specific IP in header, property or other place from client side which can be read with httpServletRequest.getRemoteAddr() on server side?

The remote address header is part of the HTTP protocol and set by the client when a request is made. You may be able to write your own client or proxy to change this header, but its unlikely that a library will explicitly provide a way for you to do this.

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