private HttpResponse SendRequestAndGetResponse(Connection connection, HttpRequest request) { _cookieStore.WriteCookiesToRequest(request); // if we need to send a body (not only headers) if (request.GetType().GetInterface("HttpEntityEnclosingRequest") != null) { var heer = (HttpEntityEnclosingRequest)request; connection.SendRequestHeaderAndEntity(request, heer.Entity, heer.ExpectContinue); } else { connection.SendRequestHeader(request); } return GetResponse(connection); }