Skip to content

default-content-type not specialized#59

Merged
cgay merged 4 commits intodylan-lang:masterfrom
kibook:patch-1
Jun 13, 2014
Merged

default-content-type not specialized#59
cgay merged 4 commits intodylan-lang:masterfrom
kibook:patch-1

Conversation

@kibook
Copy link
Copy Markdown
Contributor

@kibook kibook commented Jun 8, 2014

f83e9d4 allows default-content-type to return either a <mime-type> or a <string> (and specializes to <string> with "application/octet-stream"), but locator-media-type for <directory-resource> here expects only a <mime-type>.

Add a specialized default-content-type method for <directory-resource> which returns a new <mime-type> of application/octet-stream

f83e9d4 allows default-content-type to return either a <mime-type> or a <string> (and specializes to <string> with "application/octet-stream"), but locator-media-type for <directory-resource> here expects only a <mime-type>.

Add a specialized default-content-type method for <directory-resource> which returns a new <mime-type> of application/octet-stream
@waywardmonkeys
Copy link
Copy Markdown
Member

I'm going to leave this one for @cgay to take a look at.

@kibook
Copy link
Copy Markdown
Contributor Author

kibook commented Jun 8, 2014

I am mostly trying to figure why <directory-resource> is giving me trouble, examples using it (examples/web60/static-content.lid, and the static-content tutorial in the documentation) signalled "application/octet-stream" is not of type {<class>: <mime-type>} and would not list the directory or serve any files.

The change here has stopped that error when I run the example library, and the directory listing seems fine, but files signal an error:

No applicable method, applying {<incremental-generic-function>: write-element} to {<simple-object-vector>: {<response>}, 122}.
No applicable method, applying {function 0xfb850} to #[{<response> 0xa1b730}, 122].

I noticed changing copy-to-end in serve-static-files (server/core/static-files.dylan) from copy-to-end(in-stream, response) to copy-to-end(in-stream, response.response-stream) will serve files as expected, I'm not sure if that is a proper solution, however.

@waywardmonkeys
Copy link
Copy Markdown
Member

I agree that things have to be done and a couple of things need fixing. :) Just that @cgay is the best person as he's most familiar with the code.

If you could drop by #dylan on irc.freenode.net, it would be useful / helpful perhaps.

@cgay
Copy link
Copy Markdown
Member

cgay commented Jun 8, 2014

I don't remember why I thought it was a good idea to allow content types to be either <mime-type> or <string> but that seems questionable to me now. Especially given that the Content-type header really accepts a "media type".

I suspect the right thing is to make default-content-type always return a <byte-string> or always return a <media-type>. The latter feels kind of heavy to me, in that it imposes more burden on programmers to simply want to stuff "text/plain" in the Content-Type header, and it is certainly less efficient.

kibook@, do you want to look at changing default-content-type to always return a <byte-string>?

kibook added 3 commits June 8, 2014 16:00
Change the behaviour of locator-media-type to reflect the new generic default-content-type. Remove the specialized default-content-type as well since it is no longer needed.
Change the specialization of default-content-type to fit with the new generic interface.
cgay added a commit that referenced this pull request Jun 13, 2014
default-content-type not specialized
@cgay cgay merged commit ed5447d into dylan-lang:master Jun 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants