diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-09-02 16:42:10 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-09-02 16:42:10 +0200 |
commit | 3c9de78274d5f7e5d7c7c19105e4925a91103e9e (patch) | |
tree | 1e0027dc08663b890ecdc9b68b6543fadb394691 /container-search | |
parent | 5a10a3cc2bbad52d783e75a92c1527e33e976fe9 (diff) |
Allow setting a request type explicitly
This lets handler authors control the requestType explicitly
by setting it on the HttpResponse, which is useful to avoid
misclassification of POST requests to reading handlers as writes.
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/Result.java | 3 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/Result.java b/container-search/src/main/java/com/yahoo/search/Result.java index ab48d5797b2..6a875851ca9 100644 --- a/container-search/src/main/java/com/yahoo/search/Result.java +++ b/container-search/src/main/java/com/yahoo/search/Result.java @@ -51,7 +51,7 @@ public final class Result extends com.yahoo.processing.Response implements Clone * Headers containing "envelope" meta information to be returned with this result. * Used for HTTP getHeaders when the return protocol is HTTP. */ - private ListMap<String,String> headers = null; + private ListMap<String, String> headers = null; /** Creates a new Result where the top level hit group has id "toplevel" */ public Result(Query query) { @@ -66,7 +66,6 @@ public final class Result extends com.yahoo.processing.Response implements Clone * @param query the query which produced this result * @param hits the hit container which this will return from {@link #hits()} */ - @SuppressWarnings("deprecation") public Result(Query query, HitGroup hits) { super(query); if (query==null) throw new NullPointerException("The query reference in a result cannot be null"); diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index b0c8fbba059..bb4df325762 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -17,6 +17,7 @@ import com.yahoo.container.jdisc.VespaHeaders; import com.yahoo.container.logging.AccessLog; import com.yahoo.io.IOUtils; import com.yahoo.jdisc.Metric; +import com.yahoo.jdisc.Request; import com.yahoo.language.Linguistics; import java.util.logging.Level; import com.yahoo.net.HostName; @@ -314,6 +315,7 @@ public class SearchHandler extends LoggingRequestHandler { HttpSearchResponse response = new HttpSearchResponse(getHttpResponseStatus(request, result), result, query, renderer, extractTraceNode(query)); + response.setRequestType(Request.RequestType.READ); if (hostResponseHeaderKey.isPresent()) response.headers().add(hostResponseHeaderKey.get(), selfHostname); |