-}
-static htmlSAXHandlerPtr setupSAX(apr_pool_t* pool) {
- htmlSAXHandlerPtr sax = apr_pcalloc(pool, sizeof(htmlSAXHandler) ) ;
- sax->startDocument = NULL ;
- sax->endDocument = NULL ;
- sax->startElement = pstartElement ;
- sax->endElement = pendElement ;
- sax->characters = pcharacters ;
- sax->comment = pcomment ;
- sax->cdataBlock = pcdata ;
- return sax ;
-}
-
-static ap_regex_t* seek_meta_ctype ;
-static ap_regex_t* seek_charset ;
-static ap_regex_t* seek_meta ;
-
-static void proxy_html_child_init(apr_pool_t* pool, server_rec* s) {
- seek_meta_ctype = ap_pregcomp(pool,
- "(<meta[^>]*http-equiv[ \t\r\n='\"]*content-type[^>]*>)",
- AP_REG_EXTENDED|AP_REG_ICASE) ;
- seek_charset = ap_pregcomp(pool, "charset=([A-Za-z0-9_-]+)",
- AP_REG_EXTENDED|AP_REG_ICASE) ;
- seek_meta = ap_pregcomp(pool, "<meta[^>]*(http-equiv)[^>]*>",
- AP_REG_EXTENDED|AP_REG_ICASE) ;
-}
-
-static xmlCharEncoding sniff_encoding(request_rec* r, const char* cbuf, size_t bytes
-#ifndef GO_FASTER
- , int verbose
-#endif
- ) {
- xmlCharEncoding ret ;
- char* encoding = NULL ;
- char* p ;
- char* q ;
- ap_regmatch_t match[2] ;
- unsigned char* buf = (unsigned char*)cbuf ;
-
- VERBOSE( ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
- "Content-Type is %s", r->content_type) ) ;
-
-/* If we've got it in the HTTP headers, there's nothing to do */
- if ( r->content_type &&
- ( p = ap_strcasestr(r->content_type, "charset=") , p > 0 ) ) {
- p += 8 ;
- if ( encoding = apr_pstrndup(r->pool, p, strcspn(p, " ;") ) , encoding ) {
- if ( ret = xmlParseCharEncoding(encoding),
- ret != XML_CHAR_ENCODING_ERROR ) {
- VERBOSE( ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
- "Got charset %s from HTTP headers", encoding) ) ;
- return ret ;
- } else {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Unsupported charset %s in HTTP headers", encoding) ;
- encoding = NULL ;
- }
- }
- }