Esempio n. 1
0
/* _http_heds_to_list(): C headers to list.
*/
static u3_noun
_http_heds_to_list(u3_hhed* hed_u)
{
  if ( 0 == hed_u ) {
    return u3_nul;
  } else {
    return u3nc(u3nc(u3i_string(hed_u->nam_c),
                     hed_u->val_c ? u3i_string(hed_u->val_c) : u3_nul),
                _http_heds_to_list(hed_u->nex_u));
  }
}
Esempio n. 2
0
/* _http_request_to_noun(): translate http request into noun, or u2_none.
*/
static u2_noun
_http_request_to_noun(u2_hreq* req_u)
{
  u2_noun med, url, hed, bod;

  switch ( req_u->met_e ) {
    default: fprintf(stderr, "strange request\r\n"); return u2_none;
    case u2_hmet_put: { med = c3__put; break; }
    case u2_hmet_get: { med = c3__get; break; }
    case u2_hmet_post: { med = c3__post; break; }
  }
  url = u2_ci_string(req_u->url_c);
  hed = _http_heds_to_list(req_u->hed_u);
  bod = req_u->bod_u ? u2nc(u2_nul, _http_bods_to_octs(req_u->bod_u)) : u2_nul;

  return u2nq(med, url, hed, bod);
}