Based on the applet flags, it is possible to set .rcv_buf and .snd_buf
callback functions if necessary. If these functions are not defined for an
applet using the new API, it means the default functions must be used.
We also take care to choose the raw version or the htx version, depending on
the applet flags.
appctx->outbuf = BUF_NULL;
appctx->to_forward = 0;
- appctx->t->process = ((applet->flags & APPLET_FL_NEW_API)
- ? task_process_applet
- : task_run_applet);
+ if (applet->flags & APPLET_FL_NEW_API) {
+ appctx->t->process = task_process_applet;
+ /* Automatically set .rcv_buf and .snd_buf callback functions on default ones if not set */
+ if (applet->rcv_buf == NULL)
+ applet->rcv_buf = (applet->flags & APPLET_FL_HTX
+ ? appctx_htx_rcv_buf
+ : appctx_raw_rcv_buf);
+ if (applet->snd_buf == NULL)
+ applet->snd_buf = (applet->flags & APPLET_FL_HTX
+ ? appctx_htx_snd_buf
+ : appctx_raw_snd_buf);
+ }
+ else
+ appctx->t->process = task_run_applet;
appctx->t->context = appctx;
LIST_INIT(&appctx->buffer_wait.list);