[Devel] checking if publish message body is ok

Anca-Maria Vamanu anca at voice-system.ro
Mon Apr 30 09:48:05 CEST 2007


Hello,

The second presumption is true.

/* process the body */
    if ( get_content_length(msg) == 0 )
    {
        body.s = NULL;
        if (etag_gen)
        {
            LOG(L_ERR, "PRESENCE: handle_publish: No E-Tag and no body"
                    " present\n");

            if (slb.reply(msg, 400, &pu_400b_rpl) == -1)
            {
                 LOG(L_ERR, "PRESENCE: handle_publish: Error while sending"
                        " reply\n");
            }
            error_ret = 0;
            goto error;
        }
    }
    else
    {
        body.s=get_body(msg);
        if (body.s== NULL)
        {
            LOG(L_ERR,"PRESENCE: handle_publish: ERROR cannot extract body"
                    " from msg\n");
            goto error;
        }
        body.len= get_content_length( msg );
    }   

In here it is checked if body is empty and replied with an error code if 
it is not about a refreshing Publish.
The event specific publish handling function ( evs_publ_handl ) , 
'xml_publ_handl' in this case should only check
for the correctness of the body in case it exists. This is the 
compulsory action, there could also be any other processing.
This is why this function should not be called only when the body is not 
NULL (maybe you want to keep track of the etag
or expires or smth else).

Regards,

Anca

Juha Heinanen wrote:

>while studying presence_xml code for the purpose of implementing
>presence_mwi module, i moticed that presence_xml module defines
>xml_publ_handl that is used by presence module to check if body of
>publish message is ok.
>
>xml_publ_handl returns 1 (ok) if body is empty:
>
>	if ( get_content_length(msg) == 0 )
>		return 1;
>
>how can presence module based on this info know if body was empty or
>otherwise ok?  body namely MUST be empty when event state is refreshed
>and when event state is removed and MUST NOT be empty in initial
>publication and when state is modified.
>
>therefore, should xml_publ_handl return three values, e.g., -1 when body
>is not ok, 0 when body is empty, and 1 when non-empty body is ok?
>
>or does presence module separately check emptiness of body and only
>calls xml_publ_handl when body is not empty?  in that case, should -1 be
>returned on empty body?
>
>-- juha
>
>_______________________________________________
>Devel mailing list
>Devel at openser.org
>http://openser.org/cgi-bin/mailman/listinfo/devel
>
>  
>




More information about the Devel mailing list