Bug 29819 - HttpListener Pipelined inbound requests are ignored
Summary: HttpListener Pipelined inbound requests are ignored
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.0.0
Hardware: Macintosh Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-05-06 18:10 UTC by Jon
Modified: 2015-05-07 15:03 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Jon 2015-05-06 18:10:26 UTC
If I create a web server using C# I noticed that the second request of inbound pipelined requests are always ignored. I've tried on both 3.12.1 and 4.0.0 on Linux.

Here's my netcat command to test pipelining:
nc -v localhost 5000 < httppipe.txt 

Here's the contents of httppipe.txt:
GET /heartbeat HTTP/1.1
Host: localhost

GET /heartbeat HTTP/1.1
Host: localhost

I'm pretty confident my netcat approach works because I tested it on a Java server successfully. (Meaning I saw 2 responses)

In my C# server, I've tried both GetResult and GetResultAsync. The code with GetResultAsync is basically pulled right from the MSDN example. It looks like this:
using System;
using System.Net;
using System.Threading;

namespace WebServerTest {
    public class WebServer {

        private HttpListener listener;
        public volatile bool Active = false;

        private Thread listenThread;

        public WebServer() {
            listener = new HttpListener();
            //IAsyncResult result = 
            //this.Listener.BeginGetContext(new AsyncCallback(ListenerCallback),null);
            listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);

            this.listenThread = new Thread(new ParameterizedThreadStart(Startlistener));

        private void Startlistener(object s)
            while (true){              

        private void ProcessRequest()
            var result = listener.BeginGetContext(ListenerCallback, listener);

        public static void ListenerCallback(IAsyncResult result)
            HttpListener listener = (HttpListener) result.AsyncState;
            // Call EndGetContext to complete the asynchronous operation.
            HttpListenerContext context = listener.EndGetContext(result);
            listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
            HttpListenerRequest request = context.Request;
            // Obtain a response object.
            HttpListenerResponse response = context.Response;
            // Construct a response. 
            string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
            // Get a response stream and write the response to it.
            response.ContentLength64 = buffer.Length;
            System.IO.Stream output = response.OutputStream;
            // You must close the output stream.

Note You need to log in before you can comment on or make changes to this bug.