Commit dae9243c authored by Stewart Brodie's avatar Stewart Brodie
Browse files

HTTP 0.82

* First block of data was being thrown on the floor during
  decompression in some cases.  This is now fixed.

* Debug output now knows about cookie related SWIs and won't claim that
  they are unknown SWIs.

* Transfers which are both Chunked and compressed work correctly now.
parent 4cce117d
......@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "kernel.h"
#include "swis.h"
#include "sys/errno.h"
......@@ -118,6 +119,12 @@ int decompress(Session *ses, char *buffer, int bufsize, int toread, int *rawread
*rawread = orig_toread - toread;
return dataread;
}
else if (errno == EWOULDBLOCK) {
const ptrdiff_t outsize = (char *) ses->zstream.next_out - buffer;
*rawread = orig_toread - toread;
if (outsize > 0) return outsize;
return -1;
}
else {
*rawread = orig_toread - toread;
return dataread;
......
......@@ -411,9 +411,9 @@ _kernel_oserror *swi_handler(int swi_offset, _kernel_swi_regs *r, void *pw)
(swi_offset >= 16 && (swi_offset-16) < (sizeof(swi)/sizeof(char*))) ? "Secure" : "",
swi_offset < (sizeof(swi)/sizeof(char*)) ? swi[swi_offset] :
(swi_offset >= 16 && (swi_offset-16) < (sizeof(swi)/sizeof(char*))) ? swi[swi_offset-16] :
swi_offset == HTTP_EnumerateCookies ? "EnumerateCookies" :
swi_offset == HTTP_ConsumeCookie ? "ConsumeCookie" :
swi_offset == HTTP_AddCookie ? "AddCookie" : "UNKNOWN!",
swi_offset == (HTTP_EnumerateCookies - HTTP_00) ? "EnumerateCookies" :
swi_offset == (HTTP_ConsumeCookie - HTTP_00) ? "ConsumeCookie" :
swi_offset == (HTTP_AddCookie - HTTP_00) ? "AddCookie" : "UNKNOWN!",
r->r[1]);
#endif
e = swi_handler_2(swi_offset, r, pw);
......@@ -423,9 +423,9 @@ _kernel_oserror *swi_handler(int swi_offset, _kernel_swi_regs *r, void *pw)
(swi_offset >= 16 && (swi_offset-16) < (sizeof(swi)/sizeof(char*))) ? "Secure" : "",
swi_offset < (sizeof(swi)/sizeof(char*)) ? swi[swi_offset] :
(swi_offset >= 16 && (swi_offset-16) < (sizeof(swi)/sizeof(char*))) ? swi[swi_offset-16] :
swi_offset == HTTP_EnumerateCookies ? "EnumerateCookies" :
swi_offset == HTTP_ConsumeCookie ? "ConsumeCookie" :
swi_offset == HTTP_AddCookie ? "AddCookie" : "UNKNOWN!",
swi_offset == (HTTP_EnumerateCookies - HTTP_00) ? "EnumerateCookies" :
swi_offset == (HTTP_ConsumeCookie - HTTP_00 ) ? "ConsumeCookie" :
swi_offset == (HTTP_AddCookie - HTTP_00 ) ? "AddCookie" : "UNKNOWN!",
r->r[1],
e ? e->errmess : "<V flag clear>",
e ? "<errorblock>" : protocol_network_states(r->r[0]),
......
......@@ -37,6 +37,29 @@
/*************************************************************/
/* Output trace information to the TRACE_FILE */
/*************************************************************/
#ifdef TRACE
void protocol_fast_debug(const char *format, ...)
{
va_list ap;
#ifdef USE_SYSLOG
static char buffer[1024];
va_start(ap, format);
vsprintf(buffer, format, ap);
va_end(ap);
(void) xsyslog_logmessage("HTTP", buffer, 100);
#else
FILE *fp = fopen(DEBUG_FILENAME, "a");
if (fp != 0) {
va_start(ap, format);
(void) vfprintf(fp, format, ap);
va_end(ap);
fclose(fp);
}
#endif
}
#endif
#ifdef TRACE
void protocol_debug(const char *format, ...)
{
......
......@@ -328,23 +328,32 @@ static void http_reading_response(_kernel_swi_regs *r, Session *ses)
}
#else
dataread = decompress(ses, buffer, bufsize, toread, &rawread);
#ifdef TRACE
protocol_fast_debug("decompress returns %d, rawread=%d\n", dataread, rawread);
#endif
#endif
} else
#endif
dataread = rawread = ses->op->s_recv(ses->sd, buffer, toread, 0);
{
dataread = rawread = ses->op->s_recv(ses->sd, buffer, toread, 0);
if (dataread == -1) rawread = 0;
}
#ifdef TRACE
protocol_debug("receiving_body state: recv returns %d (errno now %d)\n", dataread, errno);
protocol_debug("receiving_body state: recv returns %d (rawread now %d) (errno now %d)\n", dataread, rawread, errno);
if (dataread > 0) {
protocol_dump(buffer, dataread);
}
#endif
if (ses->chunking) {
ses->chunk_bytes -= rawread;
}
if (dataread > 0) {
ses->sent += dataread;
http_write_data_to_client(r, buffer, dataread);
if (ses->chunking) {
ses->chunk_bytes -= rawread;
if (ses->chunk_bytes == 0 && r->r[3] > 0) {
/* See comment in block containing call to http_process_chunks about
* this tail-recursive call.
......
......@@ -21,7 +21,7 @@
title-string: AcornHTTP
; Version information
help-string: Acorn_HTTP 0.81
help-string: Acorn_HTTP 0.82
; Initialisation routine.
initialisation-code: module_init
......@@ -55,4 +55,4 @@ service-call-handler: service_handler &83E00 &83E02
vector-handlers: callevery_entry/callevery_handler,
callback_entry/callback_handler
date-string: 23 Apr 1998
date-string: 27 Apr 1998
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment