Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server should close the connection when keepalive is not true #27

Closed
carlokok opened this issue Dec 13, 2011 · 2 comments
Closed

server should close the connection when keepalive is not true #27

carlokok opened this issue Dec 13, 2011 · 2 comments

Comments

@carlokok
Copy link

atm it keeps it open till the client does, but some clients wait for the final close to consider it "Done".

@carlokok
Copy link
Author

something like:

diff --git a/Kayak/Http/Http.cs b/Kayak/Http/Http.cs
index c6614fd..f144eac 100755
--- a/Kayak/Http/Http.cs
+++ b/Kayak/Http/Http.cs
@@ -55,6 +55,7 @@ namespace Kayak.Http
 
     interface IHttpServerTransaction : IDisposable
     {
+       bool Close { get; set; }
         IPEndPoint RemoteEndPoint { get; }
         void OnResponse(HttpResponseHead response);
         bool OnResponseData(ArraySegment data, Action continuation);
diff --git a/Kayak/Http/HttpServerTransaction.cs b/Kayak/Http/HttpServerTransaction.cs
index af5eb85..ebcd903 100755
--- a/Kayak/Http/HttpServerTransaction.cs
+++ b/Kayak/Http/HttpServerTransaction.cs
@@ -40,10 +40,14 @@ namespace Kayak.Http
         public bool OnResponseData(ArraySegment data, Action continuation)
         {
             return socket.Write(data, continuation);
-        }
+        }
+
+       public bool Close { get; set; }
 
         public void OnResponseEnd()
-        {
+        {
+           if (Close)
+               socket.End();
         }
 
         public void OnEnd()
diff --git a/Kayak/Http/HttpServerTransactionDelegate.cs b/Kayak/Http/HttpServerTransactionDelegate.cs
index e9fa4ff..9484198 100755
--- a/Kayak/Http/HttpServerTransactionDelegate.cs
+++ b/Kayak/Http/HttpServerTransactionDelegate.cs
@@ -117,6 +117,7 @@ namespace Kayak.Http
                         head.Headers = new Dictionary(StringComparer.InvariantCultureIgnoreCase);
 
                     head.Headers["Connection"] = "close";
+                   Segment.Close = true;
                 }
 
                 Segment.WriteResponse(head, ignoreResponseBody ? null : body);
diff --git a/Kayak/Http/OutputQueue.cs b/Kayak/Http/OutputQueue.cs
index 90768ec..c2d3bb6 100755
--- a/Kayak/Http/OutputQueue.cs
+++ b/Kayak/Http/OutputQueue.cs
@@ -30,7 +30,19 @@ namespace Kayak.Http
 
             if (transaction != null)
                 transaction.OnContinue();
-        }
+        }
+
+       public bool Close
+       {
+           get
+           {
+               return transaction.Close;
+           }
+           set
+           {
+               transaction.Close = value;
+           }
+       }
 
         public void WriteResponse(HttpResponseHead head, IDataProducer body)
         {
diff --git a/Kayak/Net/Socket/KayakSocketState.cs b/Kayak/Net/Socket/KayakSocketState.cs
index 58a9f68..712d018 100755
--- a/Kayak/Net/Socket/KayakSocketState.cs
+++ b/Kayak/Net/Socket/KayakSocketState.cs
@@ -134,8 +134,8 @@ namespace Kayak
             if ((state & State.Connected) == 0)
                 throw new InvalidOperationException("The socket was not connected.");
 
-            if ((state & State.WriteEnded) > 0)
-                throw new InvalidOperationException("The socket was previously ended.");
+            //if ((state & State.WriteEnded) > 0)
+                //throw new InvalidOperationException("The socket was previously ended.");
 
             state |= State.WriteEnded;
 

seems to do it

@bvanderveen
Copy link
Contributor

Fixed by bvanderveen/httpmachine#7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants