Code Monkey home page Code Monkey logo

restfulie.net's People

Contributors

abraaoalves avatar hvitorino avatar leonmaia avatar mauricioaniche avatar moodmosaic avatar pedrohso avatar pedroreys avatar seixasfelipe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

restfulie.net's Issues

304 Not Modified tries to respond with View

I'm not sure if this is some kind of compound issue as I couldn't seem to reproduce this directly in the sample Web.csproj on restfulie.

I'm having an issue where I respond to a regular browser request after checking the Request.Headers["If-Modified-Since"] with a new NotModified() restfulie result. Instead of it returning to the browser immediately, it actually tries to respond with the view which then blows up spectacularly because the model is null.

As a temporary work around I had to create this class:

public class ReallyNotModified : ActionResult
{
    public override void ExecuteResult(ControllerContext context)
    {
        var response = context.HttpContext.Response;
        response.StatusCode = 304;
        response.StatusDescription = "Not Modified";

        new EmptyResult().ExecuteResult(context);
    }
}

And respond with this instead of the restfulie result.

Certain accept headers crash restfulie

Accept: text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/;q=0.9,/*;q=0.8

This will crash

AcceptHeaderToMediaType
private FormatPlusQualifier ParseFormat(string type)

 if (ContainsQualifier(type))
            {
                var typeInfo = type.Split(';');
                format = typeInfo[0].Trim();
                qualifier = Convert.ToDouble(typeInfo[1].Split('=')[1], new CultureInfo("en-US"));
            }

This gets an instance of "application/xml;image/png" which it then splits at the ; and then tries to resplit on =, however since there is no = at all, typeInfo[1] is out of bounds of the array.

System.IndexOutOfRangeExceptionIndex was outside the bounds of the array.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Restfulie.Server.Negotiation.AcceptHeaderToMediaType.ParseFormat(String type)
at Restfulie.Server.Negotiation.AcceptHeaderToMediaType.GetMediaType(String acceptHeader)
at Restfulie.Server.ActAsRestfulie.OnActionExecuting(ActionExecutingContext filterContext)

 [TestFixture]
    public class AcceptHeaderToMediaTypeTests
    {

        [Test]
        public void shouldwork()
        {
            var mediaType = acceptHeader.GetMediaType("text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8");
        }

Ao retornar um new NotFound() ele retorna a view com model null

Considere o seguinte código:

    public ActionResult Edicao(long id)
    {
        T lido = repo.Procura(id);
        if (lido == null)
            return new NotFound();
        return new OK(lido);
    }

Usando o $("#container").load() do jQuery, o restfulie tenta retorna a view, e como não foi passado nenhum modelo para a view, é lançado NullReferenceException, chegando erro 500 no client.

Deveria retorna um 404, correto?

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.