[Klone-users] response_set_field: only 1 header allowed

Stefano Barbato barbato at koanlogic.com
Mon Aug 3 11:52:14 EDT 2009


Hello Steven,

On 03/ago/09, at 12:24, Steven Van Ingelgem wrote:

> In PHP it is possible to do:
> header('WWW-Authenticate: Negotiate');
> header('WWW-Authenticate: NTLM', false);
>
> This is not possible in kloned.
> Why I would like this is because of Cache-Control parameters, so I  
> can put them in seperate headers.
> Grtz,
> Steven

You're right, there's no a straightforward way to to that but here's  
an implementation of the PHP header() function for KLone:



---[ test.kl1 ]----
<%!
     int header_line(const char *line, int replace)
     {
         header_t *h = NULL;
         field_t *f = NULL;
         field_t *ex = NULL;

         h = response_get_header(response);
         dbg_err_if(h == NULL);

         dbg_err_if(field_create(NULL, NULL, &f));

         dbg_err_if(field_set_from_line(f, line));

         if(replace == 0)
         {
             dbg_err_if(header_add_field(h, f));
         } else {
             dbg_err_if(header_set_field(h, field_get_name(f),
                         field_get_value(f)));

             /* field values will be strdup'd */
             field_free(f); f = NULL;
         }

         return 0; // ok
     err:
         if(f)
             field_free(f);
         return ~0; // err
     }
%><%
     /* replace on */
     dbg_err_if(header_line("WWW-Authenticate: Negotiate", 1));

     dbg_err_if(header_line("WWW-Authenticate: NTLM", 0));

     return;
err:
     /* error */
     return;
%>
--------------------------


bye,
stefano






More information about the klone-users mailing list