Skip to content

Commit 0782055

Browse files
committed
Modify response headers only if response has not yet been sent
If an endpoint works async the response may already been sent to the client while requests are still being send to the SPARQL endpoint. Only modify the response headers, based on the info received from the SPARQL endpoint, if it has not yet been sent to the client.
1 parent cf71cf2 commit 0782055

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

helpers/mu/sparql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ function newSparqlClient() {
3333
function query( queryString ) {
3434
console.log(queryString);
3535
return newSparqlClient().query(queryString).executeRaw().then(response => {
36-
37-
if (httpContext.get('response')) {
36+
const temp = httpContext;
37+
if (httpContext.get('response') && !httpContext.get('response').headersSent) {
3838
// set mu-auth-allowed-groups on outgoing response
3939
const allowedGroups = response.headers['mu-auth-allowed-groups'];
4040
if (allowedGroups) {

0 commit comments

Comments
 (0)