MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_content_disposition

Function parse_content_disposition

parser/parse_disposition.c:362–408  ·  view source on GitHub ↗

looks inside the message, gets the Content-Disposition hdr, parse it, builds * and fills a disposition structure for it what will be attached to hdr as * parsed link. * Returns: -1 : error * 0 : success * 1 : hdr not found */

Source from the content-addressed store, hash-verified

360 * 1 : hdr not found
361 */
362int parse_content_disposition( struct sip_msg *msg )
363{
364 struct disposition *disp;
365
366 /* look for Content-Disposition header */
367 if (msg->content_disposition==0) {
368 if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
369 goto error;
370 if (msg->content_disposition==0) {
371 LM_DBG("hdr not found\n");
372 return 1;
373 }
374 }
375
376 /* now, we have the header -> look if it isn't already parsed */
377 if (msg->content_disposition->parsed!=0) {
378 /* already parsed, nothing more to be done */
379 return 0;
380 }
381
382 /* parse the body */
383 disp = (struct disposition*)pkg_malloc(sizeof(struct disposition));
384 if (disp==0) {
385 LM_ERR("no more pkg memory\n");
386 goto error;
387 }
388 memset(disp,0,sizeof(struct disposition));
389
390 switch (parse_disposition( &(msg->content_disposition->body), disp)) {
391 case -2:
392 set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM,
393 "error parsing DISPOSITION header");
394 set_err_reply(400, "bad headers");
395 /* fall through */
396 case -1:
397 /* error when parsing the body */
398 free_disposition( &disp );
399 goto error;
400 }
401
402 /* attach the parsed form to the header */
403 msg->content_disposition->parsed = (void*)disp;
404
405 return 0;
406error:
407 return -1;
408}
409
410
411/* Prints recursive a disposition structure */

Callers 1

cpl_process_registerFunction · 0.85

Calls 4

parse_dispositionFunction · 0.85
set_err_infoFunction · 0.85
set_err_replyFunction · 0.85
free_dispositionFunction · 0.85

Tested by

no test coverage detected