Subversion Repositories wimsdev

Rev

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

Rev 11124 Rev 11128
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>
26
 
27
 
27
#include "../includes.h"
28
#include "../includes.h"
28
#include "../wimsdef.h"
29
#include "../wimsdef.h"
29
 
30
 
30
char *cheater1="User-Agent: WIMS-webget";
31
char *cheater1="User-Agent: WIMS-webget";
Line 143... Line 144...
143
      p2=getenv("w_webget_port");
144
      p2=getenv("w_webget_port");
144
      if(p1==NULL || p2==NULL) errorquit("incomplete_request");
145
      if(p1==NULL || p2==NULL) errorquit("incomplete_request");
145
      port=atoi(p2);
146
      port=atoi(p2);
146
      soc=net_connect(p1); if(soc==-1) return 1;
147
      soc=net_connect(p1); if(soc==-1) return 1;
147
      c=' '; for(p3=parm; *p3; p3++) {
148
      c=' '; for(p3=parm; *p3; p3++) {
148
          if(*p3=='\n' && c!='\r') (void)write(soc,"\r",1);
149
        if(*p3=='\n' && c!='\r') assert(write(soc,"\r",1)==1);
149
          (void)write(soc,p3,1); c=*p3;
150
        assert(write(soc,p3,1)==1);
-
 
151
        c=*p3;
150
      }
152
      }
151
      (void)write(soc,"\r\n\r\n",4);
153
      assert(write(soc,"\r\n\r\n",4)==4);
152
      pt=getenv("w_module");
154
      pt=getenv("w_module");
153
      if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) {  /* File to post? */
155
      if(pt==NULL || *pt==0 || strncmp(pt,"adm/",4)==0 ) {  /* File to post? */
154
          pt=getenv("w_webget_post"); if(pt!=NULL && *pt!=0) {
156
          pt=getenv("w_webget_post"); 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)) assert(write(soc,buf,l)==l);
162
                } while(l==sizeof(buf));
164
                } while(l==sizeof(buf));
163
                fclose(f);
165
                fclose(f);
164
            }
166
            }
165
          }
167
          }
166
      }
168
      }
Line 191... Line 193...
191
    else {*p4++=0; port=atoi(p4);}
193
    else {*p4++=0; port=atoi(p4);}
192
    if(https) {
194
    if(https) {
193
      soc=gethttps(p1); goto read;
195
      soc=gethttps(p1); goto read;
194
    }
196
    }
195
    soc=net_connect(p1);
197
    soc=net_connect(p1);
196
    (void)write(soc,tbuf,strlen(tbuf));
198
    assert(write(soc,tbuf,strlen(tbuf))==strlen(tbuf));
197
/* header */
199
/* header */
198
    read: if(soc==-1) return 1;
200
    read: if(soc==-1) return 1;
199
    c=-1;
201
    c=-1;
200
    while(read(soc,pbuf,1)>0) {
202
    while(read(soc,pbuf,1)>0) {
201
      if(pbuf[0]=='\r') continue;
203
      if(pbuf[0]=='\r') continue;