Comments (9)
The problem is that the response already has a text/html
content type and you're appending another, but specifying multiple content types isn't valid. I have no experience with Cro and don't know if this is the correct solution, but you could do .remove-header('Content-type')
before appending your own.
You might want to leave this issue open for someone more knowledgeable to chime in, there may be a more elegant way to specify it earlier in the pipeline when the response is initially constructed.
from cro-webapp.
I just had a look at your project. You're calling template
, which sets text/html by default according to the docs. Adding content-type => 'image/svg+xml'
should do the trick. And you can skip all the manual fiddling with headers. Should look something like this:
template 'templates/badge.crotmp', {
project => $project,
state => $state
},
content-type => 'image/svg+xml';
See also https://cro.services/docs/reference/cro-webapp-template and
cro-webapp/lib/Cro/WebApp/Template.pm6
Lines 190 to 195 in 3fe83a5
from cro-webapp.
.remove-header('Content-type')
did not help, get the same error. so I ended up using http permanent redirects to static images
from cro-webapp.
Odd, it worked for me in a small test directly using parts of Cro::HTTP. There must be something more going on elsewhere in the execution. Glad you have a workaround for now, though.
from cro-webapp.
@raydiak thanks a lot. Honestly I already rewritten the code to use permanent redirect, but I'll consider this solution for the future in case I decide to revert changes and go with template way ... But thanks!
PS cro supporters, should we close this issue or leave it, so someone would update the respected cro templates documentation?
from cro-webapp.
I figured, I just wanted to see it though. Serving static resources through a script is usually better avoided anyway. At least now you know how it works for the future. And you're welcome, of course!
As far as the docs go, they're pretty clear and explicit about this if you look at the one I linked. Is there another document somewhere which gave you the impression that this should work?
The only potential issues I see here are whether template
should be adding a content type if one is already set, and if multiple content types should be able to be set at all. At the least, perhaps the error could have something like "Is more than one content type specified?" appended after the parse failure message.
from cro-webapp.
template forcefully set a certain content type, without option to override the one via . append-header. This seems like a bug for me.
from cro-webapp.
The template
function (like content
, which it in turn calls) takes a content-type
option. I just checked if this is documented, and it indeed is. I have, however, tweaked content
to make sure that it overrides any existing content-type
header.
from cro-webapp.
cool, thanks
from cro-webapp.
Related Issues (20)
- content 'text/plain' silently returns 500 error when gets called with Int argument HOT 2
- Live reloading doesn't take dependencies in account
- Provide means to trim return from <:sub ...> </:>
- `<:use 'file.crotmp'>` doesn't see route level template locations
- How to template a comment HOT 1
- Handling of non-existent or empty fields HOT 1
- Can a variable be set within a template HOT 1
- Repeated use of an attribute HOT 2
- Extra data appearing in rendered template HOT 1
- Suppressing EOL / whitespace HOT 2
- Control of white space - wider problem HOT 3
- Accessing other templates with same data HOT 3
- Problems using Cro::WebApp::Template::Repository HOT 4
- How to test response from sub? HOT 1
- `Can only use 'template' inside of a request handler` is thrown in middleware
- WebApp::HTTP fails testing due to connection time-out HOT 7
- Create types for avoiding escaping HOT 5
- If Else template construct not discussed in docs HOT 3
- Missing routine route-resource-resolver HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cro-webapp.