Rev 11128 | Rev 11527 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11128 | Rev 11133 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | * Page fetched can only be sent to stdout. */ |
21 | * Page fetched can only be sent to stdout. */ |
22 | 22 | ||
23 | #include <netdb.h> |
23 | #include <netdb.h> |
24 | #include <sys/socket.h> |
24 | #include <sys/socket.h> |
25 | #include <netinet/in.h> |
25 | #include <netinet/in.h> |
26 | #include <assert.h> |
- | |
27 | 26 | ||
28 | #include "../includes.h" |
27 | #include "../includes.h" |
29 | #include "../wimsdef.h" |
28 | #include "../wimsdef.h" |
30 | 29 | ||
31 | char *cheater1="User-Agent: WIMS-webget"; |
30 | char *cheater1="User-Agent: WIMS-webget"; |
Line 144... | Line 143... | ||
144 | p2=getenv("w_webget_port"); |
143 | p2=getenv("w_webget_port"); |
145 | if(p1==NULL || p2==NULL) errorquit("incomplete_request"); |
144 | if(p1==NULL || p2==NULL) errorquit("incomplete_request"); |
146 | port=atoi(p2); |
145 | port=atoi(p2); |
147 | soc=net_connect(p1); if(soc==-1) return 1; |
146 | soc=net_connect(p1); if(soc==-1) return 1; |
148 | c=' '; for(p3=parm; *p3; p3++) { |
147 | c=' '; for(p3=parm; *p3; p3++) { |
149 | if |
148 | if(*p3=='\n' && c!='\r') (void)write(soc,"\r",1); |
150 |
|
149 | (void)write(soc,p3,1); c=*p3; |
151 | c=*p3; |
- | |
152 | } |
150 | } |
153 |
|
151 | (void)write(soc,"\r\n\r\n",4); |
154 | pt=getenv("w_module"); |
152 | pt=getenv("w_module"); |
155 | 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? */ |
156 | pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) { |
154 | pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) { |
157 | FILE *f; |
155 | FILE *f; |
158 | char buf[4096]; |
156 | char buf[4096]; |
159 | size_t l; |
157 | size_t l; |
160 | f=fopen(pt,"r"); if(f!=NULL) { |
158 | f=fopen(pt,"r"); if(f!=NULL) { |
161 | do { |
159 | do { |
162 | l=fread(buf,1,sizeof(buf),f); |
160 | l=fread(buf,1,sizeof(buf),f); |
163 | if(l>0 && l<=sizeof(buf)) |
161 | if(l>0 && l<=sizeof(buf)) (void)write(soc,buf,l); |
164 | } while(l==sizeof(buf)); |
162 | } while(l==sizeof(buf)); |
165 | fclose(f); |
163 | fclose(f); |
166 | } |
164 | } |
167 | } |
165 | } |
168 | } |
166 | } |
Line 193... | Line 191... | ||
193 | else {*p4++=0; port=atoi(p4);} |
191 | else {*p4++=0; port=atoi(p4);} |
194 | if(https) { |
192 | if(https) { |
195 | soc=gethttps(p1); goto read; |
193 | soc=gethttps(p1); goto read; |
196 | } |
194 | } |
197 | soc=net_connect(p1); |
195 | soc=net_connect(p1); |
198 |
|
196 | (void)write(soc,tbuf,strlen(tbuf)); |
199 | /* header */ |
197 | /* header */ |
200 | read: if(soc==-1) return 1; |
198 | read: if(soc==-1) return 1; |
201 | c=-1; |
199 | c=-1; |
202 | while(read(soc,pbuf,1)>0) { |
200 | while(read(soc,pbuf,1)>0) { |
203 | if(pbuf[0]=='\r') continue; |
201 | if(pbuf[0]=='\r') continue; |