Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Request aborted #335

Closed
wants to merge 21 commits into from
Closed

Request aborted #335

wants to merge 21 commits into from

Conversation

tmds
Copy link
Contributor

@tmds tmds commented Aug 20, 2015

Support RequestAborted (fixes #320)
Add PipelineCompleteAsync to wait for pipeline operations for a request to complete.

Code based on 1.0.0-beta6 branch

@dnfclas
Copy link

dnfclas commented Aug 20, 2015

Hi @tmds, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@dnfclas
Copy link

dnfclas commented Aug 20, 2015

@tmds, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

"Microsoft.AspNet.Http.Abstractions": "1.0.0-*",
"Microsoft.AspNet.FileProviders.Abstractions": "1.0.0-*",
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }
"Microsoft.AspNet.Http.Abstractions": "1.0.0-beta6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go back to *, we're working on beta8 now.

@Tratcher
Copy link
Member

lock.json files should not be checked in.

@Tratcher
Copy link
Member

Most of these changes are noise because your branch is based on master and you're trying to merge into dev. please rebase your changes onto dev directly.

{
public static class HttpResponseMessageExtensions
{
public static Task PipelineCompleteAsync(this HttpResponseMessage message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems overkill. Why can't the client just wait for the end of the response stream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is not necessary for implementing RequestAborted.
The test I was planning to write using RequestAborted has an effect on subsequent requests. I noticed the effects weren't visible immediately because when the ResponseStream returns, the pipeline hadn't finished yet.
I think it is an interesting feature independent of RequestAborted.
If you like, I can leave it out here and open another feature request?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the response stream completing before the end of the pipeline? Is it checking content-length? Or did somebody call Dispose on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test called Dispose on it to abort the request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more complicated than we want the test client to be. We want HttpClient to be used like it normally would. If you really need to control the server data structures and flow then you can call TestServer.Invoke directly.

tmds added 8 commits August 20, 2015 21:31
…o request_aborted

Conflicts:
	src/Microsoft.AspNet.Hosting.Server.Abstractions/project.json
	src/Microsoft.AspNet.Hosting/project.json
	src/Microsoft.AspNet.Server.Testing/project.json
	src/Microsoft.AspNet.TestHost/ClientHandler.cs
	src/Microsoft.AspNet.TestHost/project.json
	test/Microsoft.AspNet.Hosting.Tests/project.json
	test/Microsoft.AspNet.TestHost.Tests/project.json
@Tratcher Tratcher added this to the 1.0.0-beta8 milestone Sep 1, 2015
@@ -7,6 +7,8 @@
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Xunit;
using System.Threading;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordering, System goes first.

…ived class of OperationCanceledException may also be thrown (TaskCanceledException)
{
private readonly HttpRequestMessage _request;
private TaskCompletionSource<HttpResponseMessage> _responseTcs;
private ResponseStream _responseStream;
private ResponseFeature _responseFeature;
private CancellationTokenSource _requestAbortedSource;
private bool _pipelineFinished;

internal RequestState(HttpRequestMessage request, PathString pathBase, CancellationToken cancellationToken)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This incoming CT needs to be linked to _requestAbortedSource.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, that's on line 65

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a registration in SendAsync which calls AbortRequest, which then Cancels _requestAbortedSource. AbortRequest also calls Complete on the _responseStream.

_responseStream.Complete();
}

internal void PipelineComplete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method names should be verbs/actions. It's not clear why you renamed most of these methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renames where part of PipelineCompleteAsync feature, which has been removed.

@Tratcher
Copy link
Member

Tratcher commented Sep 2, 2015

I synced your branch and I finally understand what's wrong with your history. Your source tree is a merger of dev and master which causes a big mess. The PR needs to be based on the dev branch with no mergers. I tried cherry picking things over to dev but ran into a bunch of conflicts. Try resetting to dev and pulling your changes over by source. That will help you squash all the commits in the process.

@tmds
Copy link
Contributor Author

tmds commented Sep 2, 2015

Replaced by #345

@tmds tmds closed this Sep 2, 2015
@tmds tmds deleted the request_aborted branch September 2, 2015 18:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants