27 lines
541 B
C
27 lines
541 B
C
#include <unistd.h>
|
|
#include <libowfat/errmsg.h>
|
|
|
|
#include "nobotgate.h"
|
|
|
|
int send_headers(buffer *from, buffer *to)
|
|
{
|
|
char buf[8192];
|
|
int nread;
|
|
for (;;) {
|
|
nread=buffer_getline(from,buf,sizeof buf);
|
|
if (nread==0) { carp("EOF before header end"); return 0; }
|
|
if (nread<0) { carpsys("failed reading"); return 0; }
|
|
/* include \n */
|
|
nread++;
|
|
|
|
if (buffer_put(to,buf,nread)<0) return 0;
|
|
if (buf[0]=='\r')
|
|
break;
|
|
}
|
|
|
|
if (buffer_flush(to)<0) {
|
|
carpsys("buffer flush");
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|