⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 http_basic.c

📁 Internet Phone, Chat, Conferencing
💻 C
📖 第 1 页 / 共 4 页
字号:
    return 0;  } else {    return msg_date_d((char const **)&s, &ifr->ifr_time);  }}/** Print If-Range header */int http_if_range_e(char b[], int bsiz, http_header_t const *h, int flags){  http_if_range_t const *ifr = (http_if_range_t const *)h;  char *b0 = b, *end = b + bsiz;  if (ifr->ifr_tag) {    MSG_STRING_E(b, end, ifr->ifr_tag);    return b - b0;  } else {    return msg_date_e(b, bsiz, ifr->ifr_time);  }}/** Extra size of a http_if_range_t object. */staticint http_if_range_dup_xtra(http_header_t const *h, int offset){  http_if_range_t const *ifr = (http_if_range_t const *)h;  offset += MSG_STRING_SIZE(ifr->ifr_tag);  return offset;}/** Duplicate one If-Range header. */staticchar *http_if_range_dup_one(http_header_t *dst, http_header_t const *src,			char *b, int xtra){  http_if_range_t *ifr = dst->sh_if_range;  http_if_range_t const *o = src->sh_if_range;  char *end = b + xtra;  MSG_STRING_DUP(b, ifr->ifr_tag, o->ifr_tag);  ifr->ifr_time = o->ifr_time;  assert(b <= end);  return b;}msg_hclass_t http_if_range_class[] =HTTP_HEADER_CLASS(if_range, "If-Range", ifr_common, single, if_range);/* ====================================================================== *//**@HTTP_HEADER http_if_unmodified_since If-Unmodified-Since header. * * The @b If-Unmodified-Since header is used with a method to make it * conditional. If the requested resource has not been modified since the * time specified in this field, the server SHOULD perform the requested * operation as if the If-Unmodified-Since header were not present. Its * syntax is defined in RFC 2616 14.28 as follows: * * @code *    If-Unmodified-Since     =  "If-Unmodified-Since:" HTTP-date * @endcode * *//**@ingroup http_if_unmodified_since * @typedef typedef http_date_t http_if_unmodified_since_t; * * The structure #http_if_unmodified_since_t contains representation of  * @b If-Unmodified-Since header. * * The #http_if_unmodified_since_t is defined as follows: * @code * typedef struct { *   msg_common_t    d_common[1];        // Common fragment info *   msg_error_t    *d_next;             // Link to next (dummy) *   http_time_t     d_time;             // Seconds since Jan 1, 1900 * } http_if_unmodified_since_t; * @endcode */#define http_if_unmodified_since_d http_date_d#define http_if_unmodified_since_e http_date_emsg_hclass_t http_if_unmodified_since_class[] =HTTP_HEADER_CLASS(if_unmodified_since, "If-Unmodified-Since", 		  d_common, single, default);/* ====================================================================== *//**@HTTP_HEADER http_last_modified Last-Modified header. * * The Last-Modified header field gives the date and time after which the * message content last_modified. Its syntax is defined in [] as follows: * * @code *    Last-Modified     =  "Last-Modified:" HTTP-date * @endcode * *//**@ingroup http_last_modified * @typedef typedef struct http_last_modified_s http_last_modified_t; * * The structure #http_last_modified_t contains representation of @b * Last-Modified header. * * The #http_last_modified_t is defined as follows: * @code * typedef struct { *   msg_common_t    d_common[1];        // Common fragment info *   msg_error_t    *d_next;             // Link to next (dummy) *   http_time_t     d_time;             // Seconds since Jan 1, 1900 * } http_last_modified_t; * @endcode */#define http_last_modified_d http_date_d#define http_last_modified_e http_date_emsg_hclass_t http_last_modified_class[] =HTTP_HEADER_CLASS(last_modified, "Last-Modified", d_common, single, default);/* ====================================================================== *//**@HTTP_HEADER http_location Location Header * * The Location header is used to redirect the recipient to a location other * than the Request-URI for completion of the request or identification of a * new resource. Its syntax is defined in RFC 2616 section 14.30 as follows: * * @code *    Location       = "Location" ":" absoluteURI * @endcode * *//**@ingroup http_location * * @typedef typedef struct http_location_s http_location_t; * * The structure http_location_t contains representation of @b Location * header. * * The http_location_t is defined as follows: * @code * typedef struct http_location_s * { *   msg_common_t         loc_common[1]; *   msg_error_t         *loc_next; *   url_t                loc_url[1]; * } http_location_t; * @endcode *//** Decode (parse) a Location header */int http_location_d(su_home_t *home, msg_header_t *h, char *s, int slen){  http_location_t *loc = (http_location_t *)h;  return url_d(loc->loc_url, s);}/** Encode (print) a Location header */int http_location_e(char b[], int bsiz, msg_header_t const *h, int flags){  http_location_t const *loc = (http_location_t *)h;  return url_e(b, bsiz, loc->loc_url);}/** Calculate extra storage used by Location header field */int http_location_dup_xtra(msg_header_t const *h, int offset){  int rv = offset;  http_location_t const *loc = (http_location_t *)h;  rv += url_xtra(loc->loc_url);  return rv;}/** Duplicate a Location header field */char *http_location_dup_one(msg_header_t *dst,			    msg_header_t const *src,			    char *b, int xtra){  http_location_t *loc = (http_location_t *)dst;  http_location_t const *o = (http_location_t const *)src;  char *end = b + xtra;  URL_DUP(b, end, loc->loc_url, o->loc_url);  assert(b <= end);  return b;}msg_hclass_t http_location_class[] =HTTP_HEADER_CLASS(location, "Location", loc_common, single, location);/* ====================================================================== *//**@HTTP_HEADER http_max_forwards Max-Forwards header. */#define http_max_forwards_d msg_numeric_d#define http_max_forwards_e msg_numeric_emsg_hclass_t http_max_forwards_class[] =HTTP_HEADER_CLASS(max_forwards, "Max-Forwards", mf_common, single, numeric);/* ====================================================================== *//**@HTTP_HEADER http_pragma Pragma header. */#define http_pragma_d msg_list_d#define http_pragma_e msg_list_emsg_hclass_t http_pragma_class[] =HTTP_HEADER_CLASS_LIST(pragma, "Pragma", list);/* ====================================================================== *//**@HTTP_HEADER http_proxy_authenticate Proxy-Authenticate header. */#define http_proxy_authenticate_d msg_auth_d#define http_proxy_authenticate_e msg_auth_emsg_hclass_t http_proxy_authenticate_class[] =HTTP_HEADER_CLASS_AUTH(proxy_authenticate, "Proxy-Authenticate", append);/* ====================================================================== *//**@HTTP_HEADER http_proxy_authorization Proxy-Authorization header. */#define http_proxy_authorization_d msg_auth_d#define http_proxy_authorization_e msg_auth_emsg_hclass_t http_proxy_authorization_class[] =HTTP_HEADER_CLASS_AUTH(proxy_authorization, "Proxy-Authorization", append);/* ====================================================================== *//**@HTTP_HEADER http_range Range header. * * The Range header is used to GET one or more sub-ranges of an entity * instead of the entire entity. Its syntax is defined in RFC 2616 section * 14.35 as follows: * * @code *    Range = "Range" ":" ranges-specifier *    ranges-specifier = byte-ranges-specifier *    byte-ranges-specifier = bytes-unit "=" byte-range-set *    byte-range-set  = 1#( byte-range-spec | suffix-byte-range-spec ) *    byte-range-spec = first-byte-pos "-" [last-byte-pos] *    first-byte-pos  = 1*DIGIT *    last-byte-pos   = 1*DIGIT * @endcode * *//**@ingroup http_range * * @typedef typedef struct http_range_s http_range_t; * * The structure http_range_t contains representation of @b Range header. * * The http_range_t is defined as follows: * @code * typedef struct http_range_s * { *   msg_common_t         rng_common[1]; *   msg_error_t         *rng_next; *   char const          *rng_unit; *   char const  * const *rng_specs; * } http_range_t; * @endcode */static int range_spec_scan(char *start);/** Decode (parse) a Range header */int http_range_d(su_home_t *home, msg_header_t *h, char *s, int slen){  http_range_t *rng = (http_range_t *)h;  rng->rng_unit = s;  skip_token(&s);  if (s == rng->rng_unit)    return -1;  if (IS_LWS(*s)) {    *s++ = '\0';    skip_lws(&s);  }  if (*s != '=')    return -1;  *s++ = '\0';  skip_lws(&s);  /* XXX - use range-scanner */  return msg_commalist_d(home, &s, &rng->rng_specs, range_spec_scan);}/** Scan and compact a range spec. */staticint range_spec_scan(char *start){  int tlen;  char *s, *p;  s = p = start;  if (s[0] == ',')    return 0;  /* Three forms: 1*DIGIT "-" 1*DIGIT | 1*DIGIT "-" | "-" 1*DIGIT */  if (*s != '-') {    tlen = span_digit(s);    if (tlen == 0)      return -1;    p += tlen; s += tlen;    skip_lws(&s);  }  if (*s != '-')    return -1;  if (p != s)    *p = *s;  p++, s++; skip_lws(&s);  if (IS_DIGIT(*s)) {    tlen = span_digit(s);    if (tlen == 0)      return -1;    if (p != s)      memmove(p, s, tlen);    p += tlen; s += tlen;    skip_lws(&s);  }  if (p != s)    *p = '\0';  return s - start;}/** Encode (print) a Range header */int http_range_e(char b[], int bsiz, msg_header_t const *h, int flags){  http_range_t const *rng = (http_range_t *)h;  char *b0 = b, *end = b + bsiz;  MSG_STRING_E(b, end, rng->rng_unit);  MSG_CHAR_E(b, end, '=');  MSG_COMMALIST_E(b, end, rng->rng_specs, MSG_IS_COMPACT(flags));  MSG_TERM_E(b, end);  return b - b0;}/** Calculate extra storage used by Range header field */int http_range_dup_xtra(msg_header_t const *h, int offset){  int rv = offset;  http_range_t const *rng = (http_range_t *)h;  MSG_PARAMS_SIZE(rv, rng->rng_specs);  rv += MSG_STRING_SIZE(rng->rng_unit);  return rv;}/** Duplicate a Range header field */char *http_range_dup_one(msg_header_t *dst,			    msg_header_t const *src,			    char *b, int xtra){  http_range_t *rng = (http_range_t *)dst;  http_range_t const *o = (http_range_t const *)src;  char *end = b + xtra;  b = msg_params_dup((char const * const **)&rng->rng_specs,		     o->rng_specs, b, xtra);  MSG_STRING_DUP(b, rng->rng_unit, o->rng_unit);  assert(b <= end);  return b;}msg_hclass_t http_range_class[] =HTTP_HEADER_CLASS(range, "Range", rng_specs, single, range);/* ====================================================================== *//**@HTTP_HEADER http_referer Referer header. * * The Referer header is used to redirect the recipient to a referer other * than the Request-URI for completion of the request or identification of a * new resource. Its syntax is defined in RFC 2616 section 14.30 as follows: * * @code *    Referer       = "Referer" ":" absoluteURI * @endcode * *//**@ingroup http_referer * * @typedef typedef struct http_referer_s http_referer_t; * * The structure http_referer_t contains representation of @b Referer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -