MCPcopy Create free account
hub / github.com/apache/httpd / read_table

Function read_table

modules/cache/mod_cache_disk.c:776–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774}
775
776static apr_status_t read_table(cache_handle_t *handle, request_rec *r,
777 apr_table_t *table, apr_file_t *file)
778{
779 char w[MAX_STRING_LEN];
780 char *l;
781 apr_size_t p;
782 apr_status_t rv;
783
784 while (1) {
785
786 /* ### What about APR_EOF? */
787 rv = apr_file_gets(w, MAX_STRING_LEN - 1, file);
788 if (rv != APR_SUCCESS) {
789 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00717)
790 "Premature end of cache headers.");
791 return rv;
792 }
793
794 /* Delete terminal (CR?)LF */
795
796 p = strlen(w);
797 /* Indeed, the host's '\n':
798 '\012' for UNIX; '\015' for MacOS; '\025' for OS/390
799 -- whatever the script generates.
800 */
801 if (p > 0 && w[p - 1] == '\n') {
802 if (p > 1 && w[p - 2] == CR) {
803 w[p - 2] = '\0';
804 }
805 else {
806 w[p - 1] = '\0';
807 }
808 }
809
810 /* If we've finished reading the headers, break out of the loop. */
811 if (w[0] == '\0') {
812 break;
813 }
814
815#if APR_CHARSET_EBCDIC
816 /* Chances are that we received an ASCII header text instead of
817 * the expected EBCDIC header lines. Try to auto-detect:
818 */
819 if (!(l = strchr(w, ':'))) {
820 int maybeASCII = 0, maybeEBCDIC = 0;
821 unsigned char *cp, native;
822 apr_size_t inbytes_left, outbytes_left;
823
824 for (cp = w; *cp != '\0'; ++cp) {
825 native = apr_xlate_conv_byte(ap_hdrs_from_ascii, *cp);
826 if (apr_isprint(*cp) && !apr_isprint(native))
827 ++maybeEBCDIC;
828 if (!apr_isprint(*cp) && apr_isprint(native))
829 ++maybeASCII;
830 }
831 if (maybeASCII > maybeEBCDIC) {
832 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00718)
833 "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)",

Callers 1

recall_headersFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected