Rev 11527 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11527 | Rev 11539 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | #include <sys/socket.h> |
24 | #include <sys/socket.h> |
25 | #include <netinet/in.h> |
25 | #include <netinet/in.h> |
26 | 26 | ||
27 | #include "../includes.h" |
27 | #include "../includes.h" |
28 | #include "../wimsdef.h" |
28 | #include "../wimsdef.h" |
29 | - | ||
30 | void inline IGNORE() {} /* Ignore GCC Unused Result */ |
- | |
31 | void IGNORE(); /* see http://stackoverflow.com/a/16245669/490291 */ |
- | |
32 | 29 | ||
33 | char *cheater1="User-Agent: WIMS-webget"; |
30 | char *cheater1="User-Agent: WIMS-webget"; |
34 | char *cheater2="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n\ |
31 | char *cheater2="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n\ |
35 | Accept-Encoding: gzip\r\n\ |
32 | Accept-Encoding: gzip\r\n\ |
36 | Accept-Language: en, fr, it, de, es\r\n\ |
33 | Accept-Language: en, fr, it, de, es\r\n\ |
Line 146... | Line 143... | ||
146 | p2=getenv("w_webget_port"); |
143 | p2=getenv("w_webget_port"); |
147 | if(p1==NULL || p2==NULL) errorquit("incomplete_request"); |
144 | if(p1==NULL || p2==NULL) errorquit("incomplete_request"); |
148 | port=atoi(p2); |
145 | port=atoi(p2); |
149 | soc=net_connect(p1); if(soc==-1) return 1; |
146 | soc=net_connect(p1); if(soc==-1) return 1; |
150 | c=' '; for(p3=parm; *p3; p3++) { |
147 | c=' '; for(p3=parm; *p3; p3++) { |
151 | if(*p3=='\n' && c!='\r') |
148 | if(*p3=='\n' && c!='\r') (void)write(soc,"\r",1); |
152 |
|
149 | (void)write(soc,p3,1); c=*p3; |
153 | } |
150 | } |
154 |
|
151 | (void)write(soc,"\r\n\r\n",4); |
155 | pt=getenv("w_module"); |
152 | pt=getenv("w_module"); |
156 | if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) { /* File to post? */ |
153 | if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) { /* File to post? */ |
157 | pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) { |
154 | pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) { |
158 | FILE *f; |
155 | FILE *f; |
159 | char buf[4096]; |
156 | char buf[4096]; |
160 | size_t l; |
157 | size_t l; |
161 | f=fopen(pt,"r"); if(f!=NULL) { |
158 | f=fopen(pt,"r"); if(f!=NULL) { |
162 | do { |
159 | do { |
163 | l=fread(buf,1,sizeof(buf),f); |
160 | l=fread(buf,1,sizeof(buf),f); |
164 | if(l>0 && l<=sizeof(buf)) |
161 | if(l>0 && l<=sizeof(buf)) (void)write(soc,buf,l); |
165 | } while(l==sizeof(buf)); |
162 | } while(l==sizeof(buf)); |
166 | fclose(f); |
163 | fclose(f); |
167 | } |
164 | } |
168 | } |
165 | } |
169 | } |
166 | } |
Line 194... | Line 191... | ||
194 | else {*p4++=0; port=atoi(p4);} |
191 | else {*p4++=0; port=atoi(p4);} |
195 | if(https) { |
192 | if(https) { |
196 | soc=gethttps(p1); goto read; |
193 | soc=gethttps(p1); goto read; |
197 | } |
194 | } |
198 | soc=net_connect(p1); |
195 | soc=net_connect(p1); |
199 |
|
196 | (void)write(soc,tbuf,strlen(tbuf)); |
200 | /* header */ |
197 | /* header */ |
201 | read: if(soc==-1) return 1; |
198 | read: if(soc==-1) return 1; |
202 | c=-1; |
199 | c=-1; |
203 | while(read(soc,pbuf,1)>0) { |
200 | while(read(soc,pbuf,1)>0) { |
204 | if(pbuf[0]=='\r') continue; |
201 | if(pbuf[0]=='\r') continue; |