Skip to content

Instantly share code, notes, and snippets.

@rezan
Last active December 2, 2019 23:00
Embed
What would you like to do?
Varnish VCL JSONP support
import urlplus;
import xbody;
sub vcl_backend_response {
# Insert the JSONP callback
if (urlplus.query_get("callback") && beresp.http.Content-Type ~ "json") {
xbody.regsub("^", urlplus.query_get("callback") + "(");
xbody.regsub("$", ");");
set beresp.http.Content-Type = regsub(beresp.http.Content-Type, "json", "javascript");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment