Subversion Repositories wimsdev

Rev

Rev 11133 | Rev 11539 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11133 Rev 11527
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 */
29
 
32
 
30
char *cheater1="User-Agent: WIMS-webget";
33
char *cheater1="User-Agent: WIMS-webget";
31
char *cheater2="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n\
34
char *cheater2="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n\
32
Accept-Encoding: gzip\r\n\
35
Accept-Encoding: gzip\r\n\
33
Accept-Language: en, fr, it, de, es\r\n\
36
Accept-Language: en, fr, it, de, es\r\n\
Line 143... Line 146...
143
      p2=getenv("w_webget_port");
146
      p2=getenv("w_webget_port");
144
      if(p1==NULL || p2==NULL) errorquit("incomplete_request");
147
      if(p1==NULL || p2==NULL) errorquit("incomplete_request");
145
      port=atoi(p2);
148
      port=atoi(p2);
146
      soc=net_connect(p1); if(soc==-1) return 1;
149
      soc=net_connect(p1); if(soc==-1) return 1;
147
      c=' '; for(p3=parm; *p3; p3++) {
150
      c=' '; for(p3=parm; *p3; p3++) {
148
          if(*p3=='\n' && c!='\r') (void)write(soc,"\r",1);
151
          if(*p3=='\n' && c!='\r') IGNORE(write(soc,"\r",1));
149
          (void)write(soc,p3,1); c=*p3;
152
          IGNORE(write(soc,p3,1)); c=*p3;
150
      }
153
      }
151
      (void)write(soc,"\r\n\r\n",4);
154
      IGNORE(write(soc,"\r\n\r\n",4));
152
      pt=getenv("w_module");
155
      pt=getenv("w_module");
153
      if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) {  /* File to post? */
156
      if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) {  /* File to post? */
154
          pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) {
157
          pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) {
155
            FILE *f;
158
            FILE *f;
156
            char buf[4096];
159
            char buf[4096];
157
            size_t l;
160
            size_t l;
158
            f=fopen(pt,"r"); if(f!=NULL) {
161
            f=fopen(pt,"r"); if(f!=NULL) {
159
                do {
162
                do {
160
                  l=fread(buf,1,sizeof(buf),f);
163
                  l=fread(buf,1,sizeof(buf),f);
161
                  if(l>0 && l<=sizeof(buf)) (void)write(soc,buf,l);
164
                  if(l>0 && l<=sizeof(buf)) IGNORE(write(soc,buf,l));
162
                } while(l==sizeof(buf));
165
                } while(l==sizeof(buf));
163
                fclose(f);
166
                fclose(f);
164
            }
167
            }
165
          }
168
          }
166
      }
169
      }
Line 191... Line 194...
191
    else {*p4++=0; port=atoi(p4);}
194
    else {*p4++=0; port=atoi(p4);}
192
    if(https) {
195
    if(https) {
193
      soc=gethttps(p1); goto read;
196
      soc=gethttps(p1); goto read;
194
    }
197
    }
195
    soc=net_connect(p1);
198
    soc=net_connect(p1);
196
    (void)write(soc,tbuf,strlen(tbuf));
199
    IGNORE(write(soc,tbuf,strlen(tbuf)));
197
/* header */
200
/* header */
198
    read: if(soc==-1) return 1;
201
    read: if(soc==-1) return 1;
199
    c=-1;
202
    c=-1;
200
    while(read(soc,pbuf,1)>0) {
203
    while(read(soc,pbuf,1)>0) {
201
      if(pbuf[0]=='\r') continue;
204
      if(pbuf[0]=='\r') continue;