[
https://issues.apache.org/jira/browse/SOLR-5517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13836029#comment-13836029
]
Uwe Schindler edited comment on SOLR-5517 at 12/1/13 1:52 PM:
--------------------------------------------------------------
I looked around in the RequestHandlers:
- SearchRequestHandler is the bad guy, which does not throw SolrException, if
the request does not fit a "search". The SearchHandler should throw
SolrException, if request.streams.length>0. For a search request, there should
be not passed any streams. If you then have a typo in your content-type, the
request handler has to throw the exception, as no streams are expected (the
stream comes from the following: because the FormData parser is not invoked,
the RawRequestParser then sets a single ContentStream for any remaining content
type - in that case the one with typo).
- UpdateRequestHandler should use the new HTTP status constant here to be
consistent:
{code:java}
if( type == null ) { // Normal requests will not get here.
throw new SolrException(ErrorCode.BAD_REQUEST, "Missing ContentType");
}
int idx = type.indexOf(';');
if(idx>0) {
type = type.substring(0,idx);
}
ContentStreamLoader loader = loaders.get(type);
if(loader==null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Unsupported
ContentType: "
+type+ " Not in: "+loaders.keySet());
}
if(loader.getDefaultWT()!=null) {
setDefaultWT(req,loader);
}
loader.load(req, rsp, stream, processor);
{code}
We should change that code to send the correct HTTP status (or change the
status in the current patch to be BAD_REQUEST).
was (Author: thetaphi):
I looked around in the RequestHandlers:
- SearchRequestHandler is the bad guy, which does not throw SolrException, if
the request does not fit a "search". The SearchHandler should throw
SolrException, if request.streams.length>0. For a search request, there should
be not passed any streams. If you then have a typo in your content-type, the
request handler would throw exception (because the FormData handler is not
invoked and the RawRequestParser then sets a single ContentStream).
- UpdateRequestHandler should use the new HTTP status constant here to be
consistent:
{code:java}
if( type == null ) { // Normal requests will not get here.
throw new SolrException(ErrorCode.BAD_REQUEST, "Missing ContentType");
}
int idx = type.indexOf(';');
if(idx>0) {
type = type.substring(0,idx);
}
ContentStreamLoader loader = loaders.get(type);
if(loader==null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Unsupported
ContentType: "
+type+ " Not in: "+loaders.keySet());
}
if(loader.getDefaultWT()!=null) {
setDefaultWT(req,loader);
}
loader.load(req, rsp, stream, processor);
{code}
> Return HTTP error on POST requests with no Content-Type
> -------------------------------------------------------
>
> Key: SOLR-5517
> URL: https://issues.apache.org/jira/browse/SOLR-5517
> Project: Solr
> Issue Type: Improvement
> Reporter: Ryan Ernst
> Attachments: SOLR-5517.patch, SOLR-5517.patch
>
>
> While the http spec states requests without a content-type should be treated
> as application/octet-stream, the html spec says instead that post requests
> without a content-type should be treated as a form
> (http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1). It would be
> nice to allow large search requests from html forms, and not have to rely on
> the browser to set the content type (since the spec says it doesn't have to).
--
This message was sent by Atlassian JIRA
(v6.1#6144)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]