Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
initial jsonp work from phromo's issue#8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Newson committed Jul 11, 2009
1 parent 5077366 commit 358ec1f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public final class SearchRequest {

private final boolean rewrite_query;

private final String callback;

private final String ifNoneMatch;

public SearchRequest(final JSONObject obj, final String viewsig) throws ParseException {
Expand All @@ -84,6 +86,7 @@ public SearchRequest(final JSONObject obj, final String viewsig) throws ParseExc
this.debug = query.optBoolean("debug", false);
this.include_docs = query.optBoolean("include_docs", false);
this.rewrite_query = query.optBoolean("rewrite", false);
this.callback = query.optString("callback");

// Parse query.
this.q = Config.QP.parse(query.getString("q"));
Expand Down Expand Up @@ -252,7 +255,10 @@ public String execute(final IndexSearcher searcher) throws IOException {
headers.put("Content-Type", "text/plain");
result.put("body", escape(json.toString(2)));
} else {
result.put("json", json);
if (callback != null)
result.put("json", String.format("%s(%s)", callback, json));
else
result.put("json", json);
}

// Include headers.
Expand Down

0 comments on commit 358ec1f

Please sign in to comment.