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

Response Interceptor returning nil value does not convert to a Accepted response #6278

Closed
TharmiganK opened this issue Apr 3, 2024 · 0 comments · Fixed by ballerina-platform/module-ballerina-http#1927
Assignees
Labels
module/http Points/1 Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Milestone

Comments

@TharmiganK
Copy link
Contributor

Description:

When a response interceptor returns a nil value, the already built response is returned immediately by exiting the response pipeline. But it should return a Accepted response and should continue the response pipeline

Steps to reproduce:

Run the following service code:

import ballerina/http;

service class ResponseInterceptor1 {
    *http:ResponseInterceptor;

	remote function interceptResponse() {
		return;
	}
}

service class ResponseInterceptor2 {
    *http:ResponseInterceptor;

	remote function interceptResponse() returns string {
		return "Hello from the interceptor!";
	}
}

service http:InterceptableService /api on new http:Listener(9092) {

    public function createInterceptors() returns http:Interceptor[] {
        return [new ResponseInterceptor2(), new ResponseInterceptor1()];
    }

    resource function 'default [string... path]() returns string {
        return "Hello from the service!";
    }
}

Invoke the service using the cURL command:

$ curl -v http://localhost:9092/api/hello
*   Trying [::1]:9092...
* Connected to localhost (::1) port 9092
> GET /api/hello HTTP/1.1
> Host: localhost:9092
> User-Agent: curl/8.4.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< content-type: text/plain
< content-length: 23
< server: ballerina
< date: Wed, 3 Apr 2024 08:34:27 +0530
< 
* Connection #0 to host localhost left intact
Hello from the service!

The expected response in this case is Hello from the interceptor! (The response from the service should be overwritten by Accepted response in ResponseInterceptor1 then it should be overwritten by the ResponseInterceptor2)

Affected Versions:

Ballerina SwanLake Update 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/http Points/1 Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Projects
Archived in project
1 participant