@@ -266,8 +266,6 @@ void ngx_link_func_init_cycle(ngx_link_func_cycle_t* cycle) {
266266 is_service_on=1;
267267}
268268
269-
270-
271269void my_app_simple_get_greeting(ngx_link_func_ctx_t * ctx) {
272270 ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get");
273271
@@ -276,41 +274,56 @@ void my_app_simple_get_greeting(ngx_link_func_ctx_t *ctx) {
276274 200,
277275 "200 OK",
278276 "text/plain",
279- "greeting from ngx_link_func testing"
277+ "greeting from ngx_link_func testing",
278+ sizeof("greeting from ngx_link_func testing")-1
280279 );
281280}
282281
283282void my_app_simple_get_args(ngx_link_func_ctx_t * ctx) {
284283 ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get_args");
285284
286- ngx_link_func_write_resp(
287- ctx,
288- 200,
289- "200 OK",
290- "text/plain",
291- ctx->req_args
292- );
285+ if(ctx->req_args) {
286+ ngx_link_func_write_resp(
287+ ctx,
288+ 200,
289+ "200 OK",
290+ "text/plain",
291+ ctx->req_args,
292+ strlen(ctx->req_args)
293+ );
294+ } else {
295+ ngx_link_func_write_resp(
296+ ctx,
297+ 204,
298+ "",
299+ "text/plain",
300+ NULL,
301+ 0
302+ );
303+ }
293304}
294305
295306void my_app_simple_get_token_args(ngx_link_func_ctx_t * ctx) {
296307 ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get_token_args");
297308
298- char * tokenArgs = ngx_link_func_get_query_param(ctx, "token");
309+ char * tokenArgs = (char*) ngx_link_func_get_query_param(ctx, "token");
299310 if (! tokenArgs) {
300311 ngx_link_func_write_resp(
301312 ctx,
302313 401,
303314 "401 unauthorized",
304315 "text/plain",
305- "Token Not Found"
316+ "Token Not Found",
317+ sizeof("Token Not Found")-1
306318 );
307319 } else {
308320 ngx_link_func_write_resp(
309321 ctx,
310322 401,
311323 "401 unauthorized",
312324 "text/plain",
313- tokenArgs
325+ tokenArgs,
326+ strlen(tokenArgs)
314327 );
315328 }
316329}
@@ -323,8 +336,8 @@ void my_app_simple_post(ngx_link_func_ctx_t *ctx) {
323336 202,
324337 "202 Accepted and Processing",
325338 "text/plain",
326- ctx->req_body ,
327- ctx->req_body
339+ NULL ,
340+ 0
328341 );
329342}
330343
@@ -333,7 +346,7 @@ void my_app_simple_post(ngx_link_func_ctx_t *ctx) {
333346void my_app_simple_get_no_resp(ngx_link_func_ctx_t * ctx) {
334347 ngx_link_func_log_info(ctx, "Calling back and log from my_app_simple_get_no_resp");
335348
336-
349+ // return 404
337350}
338351
339352void ngx_link_func_exit_cycle(ngx_link_func_cycle_t* cyc) {
0 commit comments