Git Product home page Git Product logo

Comments (4)

projectgoav avatar projectgoav commented on July 24, 2024

Yep, agree with a lot of these points.

Use .NET built-in HTTP compression

What do you mean by this? Some implementations of HttpMessageHandler support compression automatically which is used. If the given MessageHandler implementation doesn't, we fallback to providing it ourselves.

Add server-side Exception checking to all (GET, POST, DELETE) requests

What are you proposing here?

Remove internal interfaces which has only one implementation

I think only API objects are exposed have public interfaces. I'll need to review this a bit more.

from e.deezer.

PoLaKoSz avatar PoLaKoSz commented on July 24, 2024

Use .NET built-in HTTP compression

Sorry, probably i wasn't completly clear. I found this SO answer to signal the server that this wrapper can understand gzip, deflate response.
Relevant code:

httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate"));

and
private Stream GetDecompessionStreamForResponse(Stream responseStream, HttpContentHeaders contentHeaders)
{
// If header is not present the Deezer may not support this compression algorithm OR the
// given HttpMessageHandler has support for automatic compression.
if (contentHeaders != null && contentHeaders.ContentEncoding.Any())
{
foreach (var entry in contentHeaders.ContentEncoding)
{
switch (entry.ToLowerInvariant())
{
case "gzip":
{
return new GZipStream(responseStream, CompressionMode.Decompress);
}
case "deflate":
{
return new DeflateStream(responseStream, CompressionMode.Decompress);
}
}
}
}
return responseStream;
}

Add server-side Exception checking to all (GET, POST, DELETE) requests

For example the

public Task<T> GetPlain<T>(string method, IList<IRequestParameter> parms = null)

method only checks (if i remember correctly) for HTTP status errors, and not inside the json response which could contain the error property. Yes, there is the GetPlainWithError method but probably this is a bit redundant in my opinion because i would probably check every server json response for any Exception.

Remove internal interfaces which has only one implementation

For example the IDeezerClient is an internal interface.

from e.deezer.

projectgoav avatar projectgoav commented on July 24, 2024

WRT your first point: The library allows you to pass an instance of the MessageHandler. if you are writing a Xamarin app for example, you can pass in the native NSUrlSessionHandler on Mac and iOS which allows you take advantage of the features of that platform. Each handler works differently and the default way works by stripping the content type headers if the handler has handled the compression.

It tries to let .NET do as much as possible before falling back to the library handling the decompression.

Add server-side Exception checking to all (GET, POST, DELETE) requests

This really should be done! :)

from e.deezer.

PoLaKoSz avatar PoLaKoSz commented on July 24, 2024

@projectgoav i am finished with the refactoring.

from e.deezer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.