1
1
package cn .com .infcn .api .test ;
2
2
3
3
import java .io .IOException ;
4
- import java .util .Date ;
5
4
6
- import org .nlpcn .jcoder .filter .TokenFilter ;
5
+ import javax .servlet .http .HttpServletRequest ;
6
+ import javax .servlet .http .HttpServletResponse ;
7
+
7
8
import 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 ;
12
9
import 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 ;
15
11
import org .slf4j .Logger ;
16
12
17
13
/**
@@ -33,21 +29,28 @@ public class TestApi {
33
29
* @param name 姓名
34
30
* @param aaa 日期
35
31
* @return 拼接好的字符串
32
+ * @throws IOException
36
33
*/
37
34
@ 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
+
40
53
}
41
54
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
+
53
56
}
0 commit comments