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

For discussion: Replatform FhirClient on HttpClient #727

Closed

Conversation

BradBarnich
Copy link
Contributor

I don't have much confidence in these changes yet. I can't get the Integration tests to pass with any of the listed DSTU2 endpoints, even before any changes.

The extent of the public API changes are:

  1. the removal of the Last... properties from IFhirClient, I felt these were problematic because they make FhirClient not threadsafe. For test code, it was trivial to write a custom httpclienthandler that captures these.
  2. the argument to the event handlers is now a HttpRequest/ResponseMessage

Most of the code was back ported from #507 that was merged into develop-r4.

Also addresses #478

Would such API changes be acceptable? Or must an HttpClient implementation remain separate?

string LastBodyAsText { get; }
HttpWebRequest LastRequest { get; }
HttpWebResponse LastResponse { get; }
Bundle.ResponseComponent LastResult { get; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

breaking change

}

public HttpWebResponse RawResponse { get; internal set; }
public byte[] Body { get; internal set; }
public HttpResponseMessage Response { get; internal set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

breaking change

@brianpos
Copy link
Collaborator

I haven't had a good look over these tests, but one if the things I'd like to see with the client is a pure streaming option that doesn't read the lot into a string first... but that has issues with the existing event handler approach.

@BradBarnich
Copy link
Contributor Author

This doesn't read the body for the event handlers, it could be a stream. But the first step of parsing reads it into a string because that is what the parsers accept, I didn't change that.

It should be possible to read the the content as a stream, create an JsonTextReader/XmlTextReader and pass that to the parser. I can give it a try

@brianpos
Copy link
Collaborator

There is a streaming version if the parsers too, in fact I believe the string version uses a string stream...

@brianpos
Copy link
Collaborator

The old code reads it so that the event handler doesn't mess with the stream as it can't rewind...

@BradBarnich
Copy link
Contributor Author

@brianpos I was playing around and I think it should be possible to serialize through a stream directly into the network request. That might reduce allocations a bit, I think one less copy of the xml/json bytes in memory. Did you have a particular use case in mind for a streaming API?

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

Successfully merging this pull request may close these issues.

4 participants