Navigation Menu

Skip to content

Commit

Permalink
change JSON's MIME type to "application/json"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo Onodera committed Nov 10, 2009
1 parent ac15379 commit 0333afc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/groonga.c
Expand Up @@ -222,7 +222,7 @@ put_response_header(grn_ctx *ctx, const char *p, const char *pe)
if (pd + 2 == p) {
GRN_TEXT_PUTS(ctx, head, "Content-Type: text/javascript\r\n\r\n");
} else if (pd + 4 == p && !memcmp(pd + 2, "on", 2)) {
GRN_TEXT_PUTS(ctx, head, "Content-Type: text/javascript\r\n\r\n");
GRN_TEXT_PUTS(ctx, head, "Content-Type: application/json\r\n\r\n");
}
} else if (pd + 3 == p && !memcmp(pd, "jpg", 3)) {
GRN_TEXT_PUTS(ctx, head, "Content-Type: image/jpeg\r\n\r\n");
Expand All @@ -245,7 +245,7 @@ put_response_header(grn_ctx *ctx, const char *p, const char *pe)
break;
}
} else {
GRN_TEXT_PUTS(ctx, head, "Content-Type: text/javascript\r\n\r\n");
GRN_TEXT_PUTS(ctx, head, "Content-Type: application/json\r\n\r\n");
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/http/test-http-schema.rb
Expand Up @@ -28,7 +28,7 @@ def teardown

def test_empty_table_list
response = get(command_path(:table_list))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
assert_equal([["id", "name", "path", "flags", "domain"]],
JSON.parse(response.body))
end
Expand Down
16 changes: 8 additions & 8 deletions test/unit/http/test-http.c
Expand Up @@ -73,7 +73,7 @@ test_get_root(void)
soupcut_client_get(client, "/", NULL);

soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body("", client);
}

Expand All @@ -83,7 +83,7 @@ test_get_status(void)
soupcut_client_get(client, "/d/status", NULL);

soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_match_body("{"
"\"alloc_count\":\\d+,"
"\"starttime\":\\d+,"
Expand All @@ -102,7 +102,7 @@ test_get_table_list(void)
soupcut_client_get(client, "/d/table_list", NULL);

soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body(
"[[\"id\",\"name\",\"path\",\"flags\",\"domain\"]]",
client);
Expand All @@ -122,7 +122,7 @@ test_get_table_list(void)
grn_test_assert_not_null(&context, users);

soupcut_client_get(client, "/d/table_list", NULL);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body(
cut_take_printf("["
"[\"id\",\"name\",\"path\",\"flags\",\"domain\"],"
Expand Down Expand Up @@ -154,7 +154,7 @@ test_get_column_list(void)

soupcut_client_get(client, "/d/column_list", "table", table_name, NULL);
soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body(
"[[\"id\",\"name\",\"path\",\"type\",\"flags\",\"domain\"]]",
client);
Expand All @@ -167,15 +167,15 @@ test_get_column_list(void)
"type", "Int8",
NULL);
soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body("true", client);

age = grn_ctx_get(&context, full_column_name, strlen(full_column_name));
grn_test_assert_not_null(&context, age);

soupcut_client_get(client, "/d/column_list", "table", table_name, NULL);
soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body(
cut_take_printf("["
"[\"id\",\"name\",\"path\",\"type\",\"flags\",\"domain\"],"
Expand Down Expand Up @@ -229,7 +229,7 @@ test_select(void)
column_name, hayamizu_age),
NULL);
soupcut_client_assert_response(client);
soupcut_client_assert_equal_content_type("text/javascript", client);
soupcut_client_assert_equal_content_type("application/json", client);
soupcut_client_assert_equal_body(
cut_take_printf("[[%d],"
"[[1],"
Expand Down
14 changes: 7 additions & 7 deletions test/unit/http/test-http.rb
Expand Up @@ -30,14 +30,14 @@ def teardown

def test_status
response = get(command_path(:status))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
assert_equal(["alloc_count", "starttime", "uptime"],
JSON.parse(response.body).keys.sort)
end

def test_table_list
response = get(command_path(:table_list))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
assert_equal([["id", "name", "path", "flags", "domain"]],
JSON.parse(response.body))

Expand All @@ -50,7 +50,7 @@ def test_table_list
assert_equal("true", response.body)

response = get(command_path(:table_list))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
table_list = JSON.parse(response.body)
header = table_list[0]
body = table_list[1]
Expand All @@ -69,7 +69,7 @@ def test_column_list
:default_tokenizer => ""))

response = get(command_path(:column_list, :table => "users"))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
assert_equal([["id", "name", "path", "type", "flags", "domain"]],
JSON.parse(response.body).sort)

Expand All @@ -81,7 +81,7 @@ def test_column_list
assert_equal("true", response.body)

response = get(command_path(:column_list, :table => "users"))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
column_list = JSON.parse(response.body)
assert_equal(2, column_list.length)
header = column_list[0]
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_load
assert_equal("1", response.body)

response = get(command_path(:select, :table => "users"))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
assert_equal([[Result::SUCCESS],
[[1],
["_id", "_key", "real_name"],
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_select_filter
private
def assert_select(expected, parameters)
response = get(command_path(:select, parameters))
assert_equal("text/javascript", response.content_type)
assert_equal("application/json", response.content_type)
assert_equal([[Result::SUCCESS],
[[expected.size],
["_id", "_key", "real_name"],
Expand Down

0 comments on commit 0333afc

Please sign in to comment.