00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __HTTP_COMPAT_H__
00025 #define __HTTP_COMPAT_H__
00026
00027 #include "ink_string++.h"
00028 #include "MIME.h"
00029 #include "RawHashTable.h"
00030 #include "Diags.h"
00031
00032 struct HttpBodySetRawData
00033 {
00034 unsigned int magic;
00035 char *set_name;
00036 char *content_language;
00037 char *content_charset;
00038 RawHashTable *table_of_pages;
00039 };
00040
00041
00042 class HttpCompat
00043 {
00044 public:
00045 static void parse_tok_list(StrList * list, int trim_quotes, const char *comma_list_str, int comma_list_len, char tok);
00046
00047 static void parse_tok_list(StrList * list, int trim_quotes, const char *comma_list_str, char tok);
00048
00049 static bool lookup_param_in_strlist(StrList * param_list, const char *param_name, char *param_val, int param_val_length);
00050
00051 static bool lookup_param_in_semicolon_string(const char *semicolon_string, int semicolon_string_len,
00052 const char *param_name, char *param_val, int param_val_length);
00053
00054 static void parse_mime_type(const char *mime_string, char *type, char *subtype, int type_len, int subtype_len);
00055
00056 static void parse_mime_type_with_len(const char *mime_string, int mime_string_len, char *type, char *subtype,
00057 int type_len, int subtype_len);
00058
00059 static bool do_header_values_rfc2068_14_43_match(MIMEField * hv1, MIMEField * hv2);
00060
00061 static float find_Q_param_in_strlist(StrList * strlist);
00062
00063 static float match_accept_language(const char *lang_str, int lang_len,
00064 StrList * acpt_lang_list,
00065 int *matching_length, int *matching_index, bool ignore_wildcards = false);
00066
00067 static float match_accept_charset(const char *charset_str, int charset_len,
00068 StrList * acpt_charset_list, int *matching_index, bool ignore_wildcards = false);
00069
00070 static const char *determine_set_by_language(RawHashTable * table_of_sets,
00071 StrList * acpt_language_list, StrList * acpt_charset_list,
00072 float *Q_best_ptr, int *La_best_ptr, int *Lc_best_ptr, int *I_best_ptr);
00073
00074 static void parse_comma_list(StrList * list, const char *comma_list_str)
00075 {
00076 parse_tok_list(list, 1, comma_list_str, ',');
00077 }
00078
00079 static void parse_comma_list(StrList * list, const char *comma_list_str, int comma_list_len)
00080 {
00081 parse_tok_list(list, 1, comma_list_str, comma_list_len, ',');
00082 }
00083
00084 static void parse_semicolon_list(StrList * list, const char *comma_list_str)
00085 {
00086 parse_tok_list(list, 1, comma_list_str, ';');
00087 }
00088
00089 static void parse_semicolon_list(StrList * list, const char *comma_list_str, int comma_list_len)
00090 {
00091 parse_tok_list(list, 1, comma_list_str, comma_list_len, ';');
00092 }
00093
00094 };
00095
00096 #endif