Skip to content

Commit

Permalink
Merge pull request #75 from dylan-lang/cleanups
Browse files Browse the repository at this point in the history
Cleanups
  • Loading branch information
cgay committed Sep 11, 2014
2 parents 0803e7e + e985e72 commit f94c144
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
1 change: 0 additions & 1 deletion documentation/source/reference/server.rst
Expand Up @@ -71,7 +71,6 @@ The HTTP-SERVER module
:keyword listeners-shutdown-notification:
:keyword lock:
:keyword media-type-map:
:keyword request-class:
:keyword server-root:
:keyword session-id:
:keyword session-max-age:
Expand Down
13 changes: 6 additions & 7 deletions server/core/response.dylan
Expand Up @@ -64,14 +64,13 @@ define open primary class <response> (<stream>, <base-http-response>)

end class <response>;

define method initialize
(response :: <response>, #rest args, #key direction = #"output")
if (direction ~= #"output")
error("<response> streams are output only. You may not specify direction: %=",
direction)
end;
define method initialize (response :: <response>, #rest args, #key)
apply(next-method, response, direction: #"output", args);
if (response.response-request.request-version == #"http/1.0")
let request = response.response-request;
if (request.request-keep-alive?)
set-header(response, "Connection", "Keep-Alive");
end if;
if (request.request-version == #"http/1.0")
response-chunked?(response) := #f;
end;
end method initialize;
Expand Down
17 changes: 4 additions & 13 deletions server/core/server.dylan
Expand Up @@ -73,9 +73,6 @@ define open class <http-server> (<multi-logger-mixin>, <abstract-router>)
constant slot clients-shutdown-notification :: <notification>,
required-init-keyword: clients-shutdown-notification:;

constant slot request-class :: subclass(<request>) = <request>,
init-keyword: request-class:;

//---TODO: response for unsupported-request-method-error MUST include
// Allow: field... Need an API for making sure that happens.
// RFC 2616, 5.1.1
Expand Down Expand Up @@ -675,8 +672,8 @@ define function %respond-top-level
block (exit-respond-top-level)
while (#t) // keep alive loop
with-simple-restart("Skip this request and continue with the next")
*request* := make(client.client-server.request-class, client: client);
let request :: <request> = *request*;
let request :: <request> = make(<request>, client: client);
*request* := request;
block (finish-request)
// More recently installed handlers take precedence...
let handler <error> = rcurry(htl-error-handler, finish-request);
Expand All @@ -696,11 +693,7 @@ define function %respond-top-level
decline-if-debugging: #f);

read-request(request);
let response = make(<response>,
request: request);
if (request.request-keep-alive?)
set-header(response, "Connection", "Keep-Alive");
end if;
let response = make(<response>, request: request);
dynamic-bind (*response* = response,
// Bound to a <page-context> when first requested.
*page-context* = #f)
Expand Down Expand Up @@ -799,9 +792,7 @@ end function send-error-response;
define method send-error-response-internal
(request :: <request>, err :: <error>)
let headers = http-error-headers(err) | make(<header-table>);
let response = make(<response>,
request: request,
headers: headers);
let response = make(<response>, request: request, headers: headers);
let one-liner = http-error-message-no-code(err);
unless (request-method(request) == #"head")
// TODO: Display a pretty error page.
Expand Down

0 comments on commit f94c144

Please sign in to comment.