@@ -11,46 +11,6 @@ enum ctype {
1111 CTYPE_TEXT
1212};
1313
14- /* ddname() convert "/index.html" -> "/DD:html(index)" */
15- static UCHAR *
16- ddname (const UCHAR * in , UCHAR * out , int size )
17- {
18- UCHAR * ext = strchr (in ,'.' );
19- UCHAR * mem = strchr (in ,'/' );
20- int extlen = ext ? strlen (ext + 1 ) : 0 ;
21- int memlen = (mem && ext ) ? (int )(ext - mem ) - 1 : 0 ;
22- int pos = 0 ;
23- int len ;
24-
25- /* we need space for "/DD:_ddname_(_member_)" */
26- if (size < sizeof ("/DD:_ddname_(_member_)" )) goto quit ;
27-
28- if (extlen < 0 OR memlen < 0 OR strchr (in , ':' )) {
29- /* doesn't look like a normal "file.ext" name */
30- out = NULL ;
31- goto quit ;
32- }
33-
34- if (extlen > 8 ) extlen = 8 ; /* limit ddname to 8 characters */
35- if (memlen > 8 ) memlen = 8 ; /* limit member name to 8 characters */
36-
37- strcpy (out , "/DD:" );
38- pos += 4 ;
39-
40- for (ext ++ ;(* ext ) && (extlen > 0 ); extlen -- ) {
41- out [pos ++ ]= * ext ++ ;
42- }
43- out [pos ++ ] = '(' ;
44- for (mem ++ ;(* mem ) && (* mem != '.' ) && (memlen > 0 ); memlen -- ) {
45- out [pos ++ ]= * mem ++ ;
46- }
47- out [pos ++ ] = ')' ;
48- out [pos ] = 0 ;
49-
50- quit :
51- return out ;
52- }
53-
5414extern int
5515httpget (HTTPC * httpc )
5616{
@@ -76,71 +36,30 @@ httpget(HTTPC *httpc)
7636 __asm__("DC\tH'0'" );
7737 }
7838
79- if (http_get_ufs (httpc )) {
80- /* try to open path asis */
81- mime = http_mime (path );
82- fp = http_open (httpc , path , mime );
83- // wtof("%s: 1 http_open(%p, \"%s\", %p) fp=%p, httpc->ufp=%p",
84- // __func__, httpc, path, mime, fp, httpc->ufp);
85- if (fp || httpc -> ufp ) goto okay ; /* file was opened */
86-
87- /* If the path is for a directory then we need to see if a
88- * "index.html" exist in this directory and open it.
89- */
90- len = strlen (path );
91- if (path [len - 1 ]== '/' ) {
92- memcpy (buf , path , len );
93- strcpy (& buf [len ], "index.html" );
94-
95- mime = http_mime (buf );
96- fp = http_open (httpc , buf , mime );
97-
98- if (fp || httpc -> ufp ) goto okay ; /* file was opened */
99- }
100- }
101-
102- if (http_cmpn (path ,"/DD:" ,4 )!= 0 &&
103- strchr (path ,'.' ) && strlen (path ) < 19 ) {
104-
105- /* convert the path to a "/DD:ddname(member)" */
106- if (ddname (path , buf , sizeof (buf ))) {
107- path = buf ;
108- http_dbgf ("ddname:\"%s\"\n" , path );
109- }
110- }
39+ /* try to open path from UFS */
11140 mime = http_mime (path );
112-
113- /* try to open the requested document */
11441 fp = http_open (httpc , path , mime );
115- // wtof("%s: 2 http_open(%p, \"%s\", %p) fp=%p, httpc->ufp=%p",
116- // __func__, httpc, path, mime, fp, httpc->ufp);
117- if (!fp && !httpc -> ufp && http_cmp (path ,"/" )== 0 ) {
118- /* try to open default documents */
119- path = "/index.html" ;
120- mime = http_mime (path );
121- fp = http_open (httpc , path , mime );
122- if (!fp && !httpc -> ufp ) {
123- path = "/default.html" ;
124- mime = http_mime (path );
125- fp = http_open (httpc , path , mime );
126- }
127- if (!fp && !httpc -> ufp ) {
128- path = "/DD:HTML(INDEX)" ;
129- mime = http_mime (path );
130- fp = http_open (httpc , path , mime );
131- }
132- if (!fp && !httpc -> ufp ) {
133- /* try another one */
134- path = "/DD:HTML(DEFAULT)" ;
135- fp = http_open (httpc , path , mime );
136- }
42+ if (fp || httpc -> ufp ) goto okay ;
43+
44+ /* If the path is for a directory, try index.html / default.html */
45+ len = strlen (path );
46+ if (path [len - 1 ]== '/' ) {
47+ memcpy (buf , path , len );
48+ strcpy (& buf [len ], "index.html" );
49+ mime = http_mime (buf );
50+ fp = http_open (httpc , buf , mime );
51+ if (fp || httpc -> ufp ) goto okay ;
52+
53+ strcpy (& buf [len ], "default.html" );
54+ mime = http_mime (buf );
55+ fp = http_open (httpc , buf , mime );
56+ if (fp || httpc -> ufp ) goto okay ;
13757 }
13858
139- if (!fp && !httpc -> ufp ) {
140- rc = http_resp_not_found (httpc , path );
141- httpc -> state = CSTATE_DONE ;
142- goto quit ;
143- }
59+ /* file not found */
60+ rc = http_resp_not_found (httpc , path );
61+ httpc -> state = CSTATE_DONE ;
62+ goto quit ;
14463
14564okay :
14665 httpc -> fp = fp ;
@@ -153,9 +72,8 @@ httpget(HTTPC *httpc)
15372 if (rc ) goto die ;
15473#if 1
15574 /* don't allow the browser to cache our html documents */
156- if (strstr (mime -> type , "html" ) ||
157- __patmat (path , "*.html" ) ||
158- __patmat (path , "/DD:HTML(*)" )) {
75+ if (strstr (mime -> type , "html" ) ||
76+ __patmat (path , "*.html" )) {
15977 rc = http_printf (httpc , "Cache-Control: no-store\r\n" );
16078 if (rc ) goto die ;
16179 }
0 commit comments