LastLine = Line;
} while (LineLen > 0);
FreeStrBuf(&HeaderName);
- /* finish linebuffered fast reading, cut the read part: */
- StrBufCutLeft(Buf, Pos - ChrPtr(Buf));
/* dbg_PrintHash(HTTPHeaders, nix, NULL); */
}
go_selected_language(); /* set locale */
#endif
- session_loop(HTTPHeaders, ReqLine, ReqType, Buf); /* do transaction */
+ session_loop(HTTPHeaders, ReqLine, ReqType, Buf, &Pos); /* do transaction */
#ifdef ENABLE_NLS
stop_selected_language(); /* unset locale */
#endif
/*
* Entry point for WebCit transaction
*/
-void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method, StrBuf *ReadBuf)
+void session_loop(HashList *HTTPHeaders,
+ StrBuf *ReqLine,
+ StrBuf *request_method,
+ StrBuf *ReadBuf,
+ const char **Pos)
{
StrBuf *Buf;
const char *pch, *pchs, *pche;
body_start = StrLength(content);
/** Read the entire input data at once. */
- client_read(&WCC->http_sock, content, ReadBuf, ContentLength + body_start);
+ client_read_to(&WCC->http_sock,
+ content,
+ ReadBuf, Pos,
+ ContentLength,
+ SLEEPING);
if (!strncasecmp(ChrPtr(ContentType), "application/x-www-form-urlencoded", 33)) {
StrBufCutLeft(content, body_start);
void do_housekeeping(void);
void smart_goto(const StrBuf *);
void worker_entry(void);
-void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *ReqType, StrBuf *ReadBuf);
+void session_loop(HashList *HTTPHeaders,
+ StrBuf *ReqLine,
+ StrBuf *ReqType,
+ StrBuf *ReadBuf,
+ const char **Pos);
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm);
void fmt_time(char *buf, size_t siz, time_t thetime);
void httpdate(char *buf, time_t thetime);
* 0 Request timed out.
* -1 Connection is broken, or other error.
*/
-int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, int bytes, int timeout)
+int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, const char **Pos, int bytes, int timeout)
{
const char *Error;
int retval = 0;
#ifdef HAVE_OPENSSL
if (is_https) {
+ long bufremain = StrLength(Buf) - (*Pos - ChrPtr(Buf));
+ StrBufAppendBufPlain(Target, *Pos, bufremain, 0);
+ *Pos = NULL;
+ FlushStrBuf(Buf);
+
while ((StrLength(Buf) + StrLength(Target) < bytes) &&
(retval >= 0))
retval = client_read_sslbuffer(Buf, timeout);
}
#endif
- if (StrLength(Buf) > 0) {/*/// todo: what if Buf > bytes?*/
- StrBufAppendBuf(Target, Buf, 0);
- }
- retval = StrBufReadBLOB(Target,
- sock,
- (StrLength(Target) > 0),
- bytes - StrLength(Target),
- &Error);
+ retval = StrBufReadBLOBBuffered(Target,
+ Buf, Pos,
+ sock,
+ 1,
+ bytes,
+ &Error);
if (retval < 0) {
lprintf(2, "client_read() failed: %s\n",
Error);
}
-
-/*
- * Read data from the client socket with default timeout.
- * (This is implemented in terms of client_read_to() and could be
- * justifiably moved out of sysdep.c)
- *
- * sock the socket fd to read from
- * buf the buffer to write to
- * bytes Number of bytes to read
- */
-int client_read(int *sock, StrBuf *Target, StrBuf *buf, int bytes)
-{
- return (client_read_to(sock, Target, buf, bytes, SLEEPING));
-}
-
-
-
/*
* Shut us down the regular way.
* signum is the signal we want to forward
int ClientGetLine(int *sock, StrBuf *Target, StrBuf *CLineBuf, const char **Pos);
int client_getln(int *sock, char *buf, int bufsiz);
-int client_read(int *sock, StrBuf *Target, StrBuf *buf, int bytes);
-int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, int bytes, int timeout);
+int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, const char **Pos, int bytes, int timeout);
int lprintf(int loglevel, const char *format, ...);
void wc_backtrace(void);
void ShutDownWebcit(void);