fix mime-type
[m6w6/ext-http] / php_http_negotiate.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2010, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id: php_http_headers_api.h 300300 2010-06-09 07:29:35Z mike $ */
14
15 #ifndef PHP_HTTP_NEGOTIATE_H
16 #define PHP_HTTP_NEGOTIATE_H
17
18 typedef char *(*php_http_negotiate_func_t)(const char *test, double *quality, HashTable *supported TSRMLS_DC);
19
20 extern char *php_http_negotiate_language_func(const char *test, double *quality, HashTable *supported TSRMLS_DC);
21 extern char *php_http_negotiate_default_func(const char *test, double *quality, HashTable *supported TSRMLS_DC);
22
23 PHP_HTTP_API HashTable *php_http_negotiate(const char *value, HashTable *supported, php_http_negotiate_func_t neg TSRMLS_DC);
24
25 static inline HashTable *php_http_negotiate_language(HashTable *supported TSRMLS_DC)
26 {
27 HashTable *result = NULL;
28 char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Language") TSRMLS_CC);
29
30 if (value) {
31 result = php_http_negotiate(value, supported, php_http_negotiate_language_func TSRMLS_CC);
32 }
33 STR_FREE(value);
34
35 return result;
36 }
37
38 static inline HashTable *php_http_negotiate_encoding(HashTable *supported TSRMLS_DC)
39 {
40 HashTable *result = NULL;
41 char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Encoding") TSRMLS_CC);
42
43 if (value) {
44 result = php_http_negotiate(value, supported, NULL TSRMLS_CC);
45 }
46 STR_FREE(value);
47
48 return result;
49 }
50
51 static inline HashTable *php_http_negotiate_charset(HashTable *supported TSRMLS_DC)
52 {
53 HashTable *result = NULL;
54 char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Charset") TSRMLS_CC);
55
56 if (value) {
57 result = php_http_negotiate(value, supported, NULL TSRMLS_CC);
58 }
59 STR_FREE(value);
60
61 return result;
62 }
63
64 static inline HashTable *php_http_negotiate_content_type(HashTable *supported TSRMLS_DC)
65 {
66 HashTable *result = NULL;
67 char *value = php_http_env_get_request_header(ZEND_STRL("Accept") TSRMLS_CC);
68
69 if (value) {
70 result = php_http_negotiate(value, supported, NULL TSRMLS_CC);
71 }
72 STR_FREE(value);
73
74 return result;
75 }
76
77
78 #endif
79
80 /*
81 * Local variables:
82 * tab-width: 4
83 * c-basic-offset: 4
84 * End:
85 * vim600: noet sw=4 ts=4 fdm=marker
86 * vim<600: noet sw=4 ts=4
87 */
88