47:ce9790523346 | 48:37a512d7b8f6 |
---|---|
60 char *ppath = pblock_findkeyval(pb_key_ppath, rq->vars); | 60 char *ppath = pblock_findkeyval(pb_key_ppath, rq->vars); |
61 | 61 |
62 /* open the file */ | 62 /* open the file */ |
63 int fd = open(ppath, O_RDONLY); | 63 int fd = open(ppath, O_RDONLY); |
64 if(fd < 0) { | 64 if(fd < 0) { |
65 perror("prepare_service_file: open"); | 65 //perror("prepare_service_file: open"); |
66 | 66 |
67 int status = 500; | 67 int status = 500; |
68 int en = errno; | 68 int en = errno; |
69 switch(en) { | 69 switch(en) { |
70 case EACCES: { | 70 case EACCES: { |
81 } | 81 } |
82 | 82 |
83 /* get stat */ | 83 /* get stat */ |
84 struct stat stat; | 84 struct stat stat; |
85 if (fstat(fd, &stat) != 0) { | 85 if (fstat(fd, &stat) != 0) { |
86 perror("prepare_service_file: stat"); | 86 //perror("prepare_service_file: stat"); |
87 | 87 |
88 protocol_status(sn, rq, 500, NULL); | 88 protocol_status(sn, rq, 500, NULL); |
89 return -1; | 89 return -1; |
90 } | 90 } |
91 | 91 |
141 sstr_t r_uri = sstr(uri); | 141 sstr_t r_uri = sstr(uri); |
142 | 142 |
143 /* open the file */ | 143 /* open the file */ |
144 int fd = open(ppath, O_RDONLY); | 144 int fd = open(ppath, O_RDONLY); |
145 if(fd < 0) { | 145 if(fd < 0) { |
146 perror("service_index: open"); | 146 //perror("service_index: open"); |
147 | 147 |
148 int status = 500; | 148 int status = 500; |
149 switch(errno) { | 149 switch(errno) { |
150 case EACCES: { | 150 case EACCES: { |
151 status = 403; | 151 status = 403; |
155 status = 404; | 155 status = 404; |
156 break; | 156 break; |
157 } | 157 } |
158 } | 158 } |
159 protocol_status(sn, rq, status, NULL); | 159 protocol_status(sn, rq, status, NULL); |
160 printf("REQ_ABORTED\n"); | 160 //printf("REQ_ABORTED\n"); |
161 return REQ_ABORTED; | 161 return REQ_ABORTED; |
162 } | 162 } |
163 | 163 |
164 DIR *dir = fdopendir(fd); | 164 DIR *dir = fdopendir(fd); |
165 if(dir == NULL) { | 165 if(dir == NULL) { |
166 protocol_status(sn, rq, 500, NULL); | 166 protocol_status(sn, rq, 500, NULL); |
167 printf("DIR is null\n"); | 167 //printf("DIR is null\n"); |
168 return REQ_ABORTED; | 168 return REQ_ABORTED; |
169 } | 169 } |
170 | 170 |
171 sbuf_t *out = sbuf_new(1024); /* output buffer */ | 171 sbuf_t *out = sbuf_new(1024); /* output buffer */ |
172 | 172 |
204 | 204 |
205 net_write(sn->csd, out->ptr, out->length); | 205 net_write(sn->csd, out->ptr, out->length); |
206 | 206 |
207 /* close */ | 207 /* close */ |
208 closedir(dir); | 208 closedir(dir); |
209 sbuf_free(out); | |
209 | 210 |
210 return REQ_PROCEED; | 211 return REQ_PROCEED; |
211 } | 212 } |
212 | 213 |
213 int send_options(pblock *pb, Session *sn, Request *rq) { | 214 int send_options(pblock *pb, Session *sn, Request *rq) { |