Rev 11539 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11539 | Rev 12248 | ||
---|---|---|---|
Line 142... | Line 142... | ||
142 | p1=getenv("w_webget_host"); |
142 | p1=getenv("w_webget_host"); |
143 | p2=getenv("w_webget_port"); |
143 | p2=getenv("w_webget_port"); |
144 | if(p1==NULL || p2==NULL) errorquit("incomplete_request"); |
144 | if(p1==NULL || p2==NULL) errorquit("incomplete_request"); |
145 | port=atoi(p2); |
145 | port=atoi(p2); |
146 | soc=net_connect(p1); if(soc==-1) return 1; |
146 | soc=net_connect(p1); if(soc==-1) return 1; |
- | 147 | c=' '; |
|
147 |
|
148 | for(p3=parm; *p3; p3++) { |
148 | if(*p3=='\n' && c!='\r') (void)write(soc,"\r",1); |
149 | if(*p3=='\n' && c!='\r') (void)write(soc,"\r",1); |
149 | (void)write(soc,p3,1); c=*p3; |
150 | (void)write(soc,p3,1); c=*p3; |
150 | } |
151 | } |
151 | (void)write(soc,"\r\n\r\n",4); |
152 | (void)write(soc,"\r\n\r\n",4); |
152 | pt=getenv("w_module"); |
153 | pt=getenv("w_module"); |
153 | if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) { /* File to post? */ |
154 | if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) { /* File to post? */ |
154 |
|
155 | pt=getenv("w_webget_post"); |
- | 156 | if(pt!=NULL && *pt!=0) { |
|
155 | FILE *f; |
157 | FILE *f; |
156 | char buf[4096]; |
158 | char buf[4096]; |
157 | size_t l; |
159 | size_t l; |
158 | f=fopen(pt,"r"); if(f!=NULL) { |
160 | f=fopen(pt,"r"); if(f!=NULL) { |
159 | do { |
161 | do { |
160 | l=fread(buf,1,sizeof(buf),f); |
162 | l=fread(buf,1,sizeof(buf),f); |
161 | if(l>0 && l<=sizeof(buf)) (void)write(soc,buf,l); |
163 | if(l>0 && l<=sizeof(buf)) (void)write(soc,buf,l); |
- | 164 | } |
|
162 |
|
165 | while(l==sizeof(buf)); |
163 | fclose(f); |
166 | fclose(f); |
164 | } |
167 | } |
165 | } |
168 | } |
166 | } |
169 | } |
167 | if(strstr(dp,"normalread")!=NULL) goto read; |
170 | if(strstr(dp,"normalread")!=NULL) goto read; |
Line 171... | Line 174... | ||
171 | } |
174 | } |
172 | close(soc); |
175 | close(soc); |
173 | return 0; |
176 | return 0; |
174 | } |
177 | } |
175 | if(strncasecmp(p1,"http://",strlen("http://"))==0) p1+=strlen("http://"); |
178 | if(strncasecmp(p1,"http://",strlen("http://"))==0) p1+=strlen("http://"); |
- | 179 | else |
|
176 |
|
180 | if(strncasecmp(p1,"https://",strlen("https://"))==0) { |
177 | https=1; p1+=strlen("https://"); |
181 | https=1; p1+=strlen("https://"); |
178 | } |
182 | } |
179 | p3=strchr(p1,'/'); if(p3==NULL) p3=""; |
183 | p3=strchr(p1,'/'); if(p3==NULL) p3=""; |
180 | else {*p3++=0; while(*p3=='/') p3++;} |
184 | else {*p3++=0; while(*p3=='/') p3++;} |
181 | if(strncasecmp(p3,"http://",strlen("http://"))==0 || |
185 | if(strncasecmp(p3,"http://",strlen("http://"))==0 || |
Line 183... | Line 187... | ||
183 | else pre="/"; |
187 | else pre="/"; |
184 | snprintf(tbuf,sizeof(tbuf),"GET %s%s HTTP/1.0\r\n%s\r\n\ |
188 | snprintf(tbuf,sizeof(tbuf),"GET %s%s HTTP/1.0\r\n%s\r\n\ |
185 | Host: %s\r\n\ |
189 | Host: %s\r\n\ |
186 | %s\r\n\r\n", |
190 | %s\r\n\r\n", |
187 | pre,p3,cheater1,p1,cheater2); |
191 | pre,p3,cheater1,p1,cheater2); |
188 |
|
192 | p4=strchr(p1,':'); |
- | 193 | if(p4==NULL) { |
|
189 | if(https) port=443; else port=80; |
194 | if(https) port=443; else port=80; |
190 | } |
195 | } |
191 | else {*p4++=0; port=atoi(p4);} |
196 | else {*p4++=0; port=atoi(p4);} |
192 | if(https) { |
197 | if(https) { |
193 | soc=gethttps(p1); goto read; |
198 | soc=gethttps(p1); goto read; |