1. Brief description
Referer, origin is used to indicate that the browser indicates to the Web server where it is coming from.
But as far as it is concerned, it is not entirely safe.
To write an example, you can arbitrarily modify the HTTP information in the header of Referer, origin
2. Preparation:
Using httpClient4.0 to achieve the specific
3, Java Modify the HTTP information header Referer, Origin source code
The code is so simple that it modifies the HTTP header's Referer, origin.
JSP for the companion example in: http://blog.csdn.net/ffm83/article/details/44095025
The source code is as follows:
/*** Modify the Referer property with httpclient emulation for web security examples only. * * @authorAuth*/ Public classEasymodifyheader { Public Static voidMain (string[] args)throwsException {closeablehttpclient httpclient=Httpclients.createdefault (); Try{String URL= "http://www.wuranyubao.cn/wryb_rdcity.php"; HttpPost HttpPost=Newhttppost (URL); //setting anti-outer chain header informationHttppost.setheader ("origin", "http://www.wuranyubao.cn"); Httppost.setheader ("Referer", "Http://www.wuranyubao.cn/wryb_prev.php?movie=no"); //Creating HttpPost ObjectsList<namevaluepair> params=NewArraylist<namevaluepair>(); //Create an Namevaluepair array to store the parameters to be transferredParams.add (NewBasicnamevaluepair ("Rdcity", "shandong,jinan,20151121")); Httppost.setentity (Newurlencodedformentity (params,http. Utf_8)); Closeablehttpresponse Response=Httpclient.execute (HttpPost); Try{httpentity entity=response.getentity (); //Print target Web site output contentSystem.out.println (entityutils.tostring (entity)); Entityutils.consume (entity); } finally{response.close (); } } finally{httpclient.close (); } }}
This article transferred from: http://www.2cto.com/Article/201503/380951.html
Jar Package Download: http://download.csdn.net/detail/y515789/8470829
Watch your door.-Client data-Modify Referer in Java