24
24
25
25
class IndexController extends Controller
26
26
{
27
- // curl "172.16.0.161:28887 /Index/index" -i
27
+ // curl "node_ip:port /Index/index" -i
28
28
public function actionIndex ()
29
29
{
30
30
$ this ->cookie ('key ' , 1 , 10000000 , '/ ' , 'www.github.com ' );
31
31
$ this ->sendRaw ('success ' );
32
32
}
33
33
34
- // curl "172.16.0.161:28887 /Index/testHeader" -i
34
+ // curl "node_ip:port /Index/testHeader" -i
35
35
public function actionTestHeader ()
36
36
{
37
37
$ this ->header ('test ' , 1111 );
38
38
}
39
39
40
- // curl "172.16.0.161:28887 /Index/testStatus" -i
40
+ // curl "node_ip:port /Index/testStatus" -i
41
41
public function actionTestStatus ()
42
42
{
43
43
$ this ->status (401 );
44
44
}
45
45
46
46
// Get请求
47
- // curl "172.16.0.161:28887 /Index/get?param=1111&c=d&d=e&e=f" -i
47
+ // curl "node_ip:port /Index/get?param=1111&c=d&d=e&e=f" -i
48
48
public function actionGet ()
49
49
{
50
50
$ param = $ this ->request ->data ['get ' ]['param ' ];
@@ -53,28 +53,28 @@ public function actionGet()
53
53
}
54
54
55
55
// Post请求
56
- // curl -d "user=admin&passwd=12345678" "172.16.0.161:28887 /Index/post " -i
56
+ // curl -d "user=admin&passwd=12345678" "node_ip:port /Index/post1 " -i
57
57
public function actionPost1 ()
58
58
{
59
59
// 对于content-type为application/x-www-form-urlencoded 的form data
60
- $ admin = $ this ->request ->data ['post ' ]['admin ' ];
60
+ $ admin = $ this ->request ->data ['post ' ]['user ' ];
61
61
62
62
$ this ->sendRaw ('success: ' .$ admin );
63
63
}
64
64
65
65
// Post请求
66
- //curl -H "Content-Type:application/json" -X POST -d '{"user": "admin", "passwd":"12345678"}' "172.16.0.161:28887 /Index/post " -i
66
+ //curl -H "Content-Type:application/json" -X POST -d '{"user": "admin", "passwd":"12345678"}' "node_ip:port /Index/post2 " -i
67
67
public function actionPost2 ()
68
68
{
69
69
// 对于对于content-type为application/json
70
70
$ json = $ this ->request ->data ['post ' ];
71
- $ admin = json_decode ($ json , true )['admin ' ];
71
+ $ admin = json_decode ($ json , true )['user ' ];
72
72
73
73
$ this ->sendRaw ('success: ' .$ admin );
74
74
}
75
75
76
76
// Get请求
77
- // curl -F "[email protected] " -F "phone=123456789" "172.16.0.161:28887 /Index/file" -i
77
+ // curl -F "[email protected] " -F "phone=123456789" "node_ip:port /Index/file" -i
78
78
public function actionFile ()
79
79
{
80
80
$ fileName = $ this ->request ->data ['files ' ]['image ' ]['name ' ];
@@ -85,21 +85,7 @@ public function actionFile()
85
85
$ this ->sendRaw ('success: ' .var_export ($ this ->request ->data ['files ' ]['image ' ], true ));
86
86
}
87
87
88
- // curl "172.16.0.161:28887/Index/testSelf?a=b" -i
89
- public function actionTestSelf ()
90
- {
91
- $ config = new CommunicatorConfig ();
92
- $ config ->setLocator (ENVConf::getLocator ());
93
- $ config ->setModuleName ('PHPTest.PHPHttpServer ' );
94
- $ config ->setSocketMode (3 );
95
-
96
- $ servant = new TestTafServiceServant ($ config );
97
- $ result = $ servant ->testSelf ();
98
-
99
- $ this ->sendRaw ('result: ' .$ result );
100
- }
101
-
102
- // curl "172.16.0.161:28887/Index/TestProperty?a=b" -i
88
+ // curl "node_ip:port/Index/TestProperty?a=b" -i
103
89
public function actionTestProperty ()
104
90
{
105
91
$ config = new CommunicatorConfig ();
@@ -113,7 +99,7 @@ public function actionTestProperty()
113
99
$ this ->sendRaw ('result: ' .$ result );
114
100
}
115
101
116
- // curl "172.16.0.161:28887 /Index/TestLotofTags?a=b" -i
102
+ // curl "node_ip:port /Index/TestLotofTags?a=b" -i
117
103
public function actionTestLotofTags ()
118
104
{
119
105
$ config = new CommunicatorConfig ();
@@ -131,7 +117,7 @@ public function actionTestLotofTags()
131
117
$ this ->sendRaw (json_encode ($ outTags , JSON_UNESCAPED_UNICODE ));
132
118
}
133
119
134
- // curl "172.16.0.161:28887 /Index/TestBasic?a=b" -i
120
+ // curl "node_ip:port /Index/TestBasic?a=b" -i
135
121
public function actionTestBasic ()
136
122
{
137
123
$ config = new CommunicatorConfig ();
@@ -145,7 +131,7 @@ public function actionTestBasic()
145
131
$ this ->sendRaw (json_encode ([$ d , $ e , $ f , $ ret ], JSON_UNESCAPED_UNICODE ));
146
132
}
147
133
148
- // curl "172.16.0.161:28887 /Index/TestStruct?a=b" -i
134
+ // curl "node_ip:port /Index/TestStruct?a=b" -i
149
135
public function actionTestStruct ()
150
136
{
151
137
$ config = new CommunicatorConfig ();
@@ -165,7 +151,7 @@ public function actionTestStruct()
165
151
$ this ->sendRaw (json_encode ([$ d , $ str ], JSON_UNESCAPED_UNICODE ));
166
152
}
167
153
168
- // curl "172.16.0.161:28887 /Index/TestMap?a=b" -i
154
+ // curl "node_ip:port /Index/TestMap?a=b" -i
169
155
public function actionTestMap ()
170
156
{
171
157
$ config = new CommunicatorConfig ();
@@ -185,10 +171,10 @@ public function actionTestMap()
185
171
$ d = new OutStruct ();
186
172
$ result = $ servant ->testMap (88 , $ b , $ m1 , $ d , $ m2 );
187
173
188
- $ this ->sendRaw ('result: ' .$ result );
174
+ $ this ->sendRaw ('result: ' .$ result . ' : ' . json_encode ( compact ( ' d ' , ' m2 ' )) );
189
175
}
190
176
191
- // curl "172.16.0.161:28887 /Index/TestVector?a=b" -i
177
+ // curl "node_ip:port /Index/TestVector?a=b" -i
192
178
public function actionTestVector ()
193
179
{
194
180
$ config = new CommunicatorConfig ();
@@ -208,7 +194,7 @@ public function actionTestVector()
208
194
$ this ->sendRaw (json_encode ([$ v3 , $ v4 ], JSON_UNESCAPED_UNICODE ));
209
195
}
210
196
211
- // curl "172.16.0.161:28887 /Index/TestReturn?a=b" -i
197
+ // curl "node_ip:port /Index/TestReturn?a=b" -i
212
198
public function actionTestReturn ()
213
199
{
214
200
$ config = new CommunicatorConfig ();
@@ -222,7 +208,7 @@ public function actionTestReturn()
222
208
$ this ->sendRaw (json_encode ($ simpleStruct , JSON_UNESCAPED_UNICODE ));
223
209
}
224
210
225
- // curl "172.16.0.161:28887 /Index/TestReturn2?a=b" -i
211
+ // curl "node_ip:port /Index/TestReturn2?a=b" -i
226
212
public function actionTestReturn2 ()
227
213
{
228
214
$ config = new CommunicatorConfig ();
@@ -236,7 +222,7 @@ public function actionTestReturn2()
236
222
$ this ->sendRaw (json_encode ($ map , JSON_UNESCAPED_UNICODE ));
237
223
}
238
224
239
- // curl "172.16.0.161:28887 /Index/TestComplicatedStruct?a=b" -i
225
+ // curl "node_ip:port /Index/TestComplicatedStruct?a=b" -i
240
226
public function actionTestComplicatedStruct ()
241
227
{
242
228
$ config = new CommunicatorConfig ();
@@ -258,10 +244,10 @@ public function actionTestComplicatedStruct()
258
244
259
245
$ result = $ servant ->testComplicatedStruct ($ cs , $ vcs , $ ocs , $ ovcs );
260
246
261
- $ this ->sendRaw ('result: ' .$ result );
247
+ $ this ->sendRaw ('result: ' .json_encode ( compact ( ' result ' , ' ocs ' , ' ovcs ' )) );
262
248
}
263
249
264
- // curl "172.16.0.161:28887 /Index/TestComplicatedMap?a=b" -i
250
+ // curl "node_ip:port /Index/TestComplicatedMap?a=b" -i
265
251
public function actionTestComplicatedMap ()
266
252
{
267
253
$ config = new CommunicatorConfig ();
@@ -284,7 +270,7 @@ public function actionTestComplicatedMap()
284
270
$ this ->sendRaw (json_encode ($ omcs , JSON_UNESCAPED_UNICODE ));
285
271
}
286
272
287
- // curl "172.16.0.161:28887 /Index/TestEmpty?a=b" -i
273
+ // curl "node_ip:port /Index/TestEmpty?a=b" -i
288
274
public function actionTestEmpty ()
289
275
{
290
276
$ config = new CommunicatorConfig ();
@@ -300,14 +286,14 @@ public function actionTestEmpty()
300
286
$ this ->sendRaw (json_encode ([$ ret ], JSON_UNESCAPED_UNICODE ));
301
287
}
302
288
303
- // curl "172.16.0.161:28887 /Index/TestConf?a=b" -i
289
+ // curl "node_ip:port /Index/TestConf?a=b" -i
304
290
public function actionTestConf ()
305
291
{
306
292
$ tarsConf = ENVConf::getTarsConf ();
307
293
$ this ->sendRaw (json_encode ($ tarsConf , JSON_UNESCAPED_UNICODE ));
308
294
}
309
295
310
- // curl "172.16.0.161:28887 /Index/TestRemoteLog?a=b" -i
296
+ // curl "node_ip:port /Index/TestRemoteLog?a=b" -i
311
297
public function actionTestRemoteLog ()
312
298
{
313
299
$ config = new \Tars \client \CommunicatorConfig ();
@@ -316,12 +302,12 @@ public function actionTestRemoteLog()
316
302
$ config ->setCharsetName ('UTF-8 ' );
317
303
318
304
$ logServant = new \Tars \log \LogServant ($ config );
319
- $ result = $ logServant ->logger ('PHPTest ' , 'PHPHttpServer ' , 'ted.log ' , '%Y%m%d ' , ['hahahahaha ' ]);
305
+ $ logServant ->logger ('PHPTest ' , 'PHPHttpServer ' , 'ted.log ' , '%Y%m%d ' , ['hahahahaha ' ]);
320
306
321
- $ this ->sendRaw (json_encode ( $ result , JSON_UNESCAPED_UNICODE ) );
307
+ $ this ->sendRaw (' wrote hahahahaha to ted.log ' );
322
308
}
323
309
324
- // curl "172.16.0.161:28887 /Index/TestMonolog?a=b" -i
310
+ // curl "node_ip:port /Index/TestMonolog?a=b" -i
325
311
public function actionTestMonolog ()
326
312
{
327
313
$ config = new \Tars \client \CommunicatorConfig ();
0 commit comments