11package cn .com .infcn .api .test ;
22
33import java .io .IOException ;
4- import java .util .Date ;
54
6- import org .nlpcn .jcoder .filter .TokenFilter ;
5+ import javax .servlet .http .HttpServletRequest ;
6+ import javax .servlet .http .HttpServletResponse ;
7+
78import org .nlpcn .jcoder .run .annotation .Execute ;
8- import org .nlpcn .jcoder .util .Restful ;
9- import org .nlpcn .jcoder .util .Testing ;
10- import org .nutz .http .Http ;
11- import org .nutz .http .Response ;
129import org .nutz .ioc .loader .annotation .Inject ;
13- import org .nutz .mvc .annotation .By ;
14- import org .nutz .mvc .annotation .Filters ;
10+ import org .nutz .mvc .Mvcs ;
1511import org .slf4j .Logger ;
1612
1713/**
@@ -33,21 +29,28 @@ public class TestApi {
3329 * @param name 姓名
3430 * @param aaa 日期
3531 * @return 拼接好的字符串
32+ * @throws IOException
3633 */
3734 @ Execute
38- public Restful test (String name , Date aaa ) {
39- return Restful .instance ("ok" );
35+ public void test () throws IOException {
36+ HttpServletRequest request = Mvcs .getReq () ;
37+ HttpServletResponse response = Mvcs .getResp () ;
38+
39+ String characterEncode = request .getCharacterEncoding ();
40+ String agent = request .getHeader ("User-Agent" );
41+ boolean isMSIE = (agent != null && agent .indexOf ("Firefox" ) != -1 );
42+
43+ String filename = java .net .URLEncoder .encode ("我爱北京天安门.doc" );
44+
45+ response .setCharacterEncoding (characterEncode );
46+ response .setContentType ("application/octet-stream" );
47+ String exportType = "rdf" ;
48+
49+ response .setHeader ("Content-Disposition" , "attachment;fileName=" +filename +"." +exportType );
50+ response .getOutputStream ().write ("aaaaaaaaaaaa" .getBytes ());
51+ response .getOutputStream ().flush ();
52+
4053 }
4154
42- public static void main (String [] args ) throws IOException {
43- for (int i = 0 ; i < 1000000 ; i ++) {
44- try {
45- Response response = Http .get ("http://localhost:9085/IFCMonitorServlet" ) ;
46-
47- System .out .println (response .getContent ());
48- } catch (Exception e ) {
49- e .printStackTrace ();
50- }
51- }
52- }
55+
5356}
0 commit comments