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

SendResponse in BeforeRouting Does Not Stop Processing #187

Closed
tmontney opened this issue Aug 10, 2017 · 0 comments
Closed

SendResponse in BeforeRouting Does Not Stop Processing #187

tmontney opened this issue Aug 10, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@tmontney
Copy link

tmontney commented Aug 10, 2017

Public Class Form1
    Dim svr As Grapevine.Server.RestServer
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        svr = New Grapevine.Server.RestServer
        With svr
            .Port = 80
            .Host = "0.0.0.0"
            .UseHttps = False
            AddHandler svr.Router.BeforeRouting, AddressOf BeforeRouting
            .LogToConsole.Start()
        End With
    End Sub

    Private Sub BeforeRouting(ByVal Context As Grapevine.Interfaces.Server.HttpContext)
        Dim Serializer As New System.Web.Script.Serialization.JavaScriptSerializer
        Dim Value As Object = Serializer.DeserializeObject(Context.Request.Payload)

        Try
            Integer.Parse(Value("Value"))
        Catch ex As Exception
            Context.Response.SendResponse(System.Text.ASCIIEncoding.ASCII.GetBytes("401"))
        End Try
    End Sub

    <Grapevine.Server.Attributes.RestResource>
    Public Class RestRoutes
        <Grapevine.Server.Attributes.RestRoute(HttpMethod:=Grapevine.Shared.HttpMethod.POST, PathInfo:="/TEST")>
        Public Function TestRoute(ByVal Context As Grapevine.Interfaces.Server.IHttpContext) As Grapevine.Interfaces.Server.IHttpContext
            Context.Response.SendResponse(System.Text.ASCIIEncoding.ASCII.GetBytes("200"))

            Return Context
        End Function
    End Class
End Class

In the above example, if data that is sent to the server is not an integer, the server should send prematurely and halt processing. Server sends prematurely but does not stop processing, and tries to execute intended route.

@scottoffen scottoffen self-assigned this Aug 11, 2017
scottoffen pushed a commit that referenced this issue Aug 16, 2017
@scottoffen scottoffen added this to the 4.1.1.0 milestone Aug 21, 2017
@scottoffen scottoffen changed the title SendResponse in BeforeRouting doesn't stop processing SendResponse in BeforeRouting Does Not Stop Processing Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants