Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ensure that the correct content-type is returned. #18

Merged
merged 2 commits into from

3 participants

@cmeiklejohn
Collaborator

Currently, web browsers such as Chrome throw warnings for each resource which is returned with the wrong content type. Modify the content-types-provided method to inspect the resource and return a best guess at the appropriate mime-type.

@massung @jgnewman

@cmeiklejohn cmeiklejohn Ensure that the correct content-type is returned.
This prevents browsers from complaining about individual resources
coming in with the wrong content type.
32a6e4a
src/admin_gui.erl
((13 lines not shown))
Path=wrq:path_tokens(Req),
Index=filename:join([riak_control:priv_dir(),"admin"] ++ Path),
+ Index.

That line is unnecessary, the assignment is unused except as a return value.

@cmeiklejohn Collaborator

Removed in 0a50194.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@massung

+1

@cmeiklejohn cmeiklejohn merged commit 2638a66 into master
@seancribbs seancribbs deleted the cm-ensure-content-type branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 28, 2012
  1. @cmeiklejohn

    Ensure that the correct content-type is returned.

    cmeiklejohn authored
    This prevents browsers from complaining about individual resources
    coming in with the wrong content type.
  2. @cmeiklejohn

    Remove redundant line.

    cmeiklejohn authored
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/admin_gui.erl
View
12 src/admin_gui.erl
@@ -75,12 +75,18 @@ is_authorized (RD,C) ->
%% return the list of available content types for webmachine
content_types_provided (Req,Ctx) ->
- {?CONTENT_TYPES,Req,Ctx}.
+ Index = file_path(Req),
+ MimeType = webmachine_util:guess_mime(Index),
+ {[{MimeType, to_resource}],Req, Ctx}.
+
+%% return file path
+file_path(Req) ->
+ Path=wrq:path_tokens(Req),
+ filename:join([riak_control:priv_dir(),"admin"] ++ Path).
%% loads a resource file from disk and returns it
get_file (Req) ->
- Path=wrq:path_tokens(Req),
- Index=filename:join([riak_control:priv_dir(),"admin"] ++ Path),
+ Index = file_path(Req),
{ok,Source}=file:read_file(Index),
Source.
Something went wrong with that request. Please try again.