Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
error.setContent ("<p>Request doesn't have a valid content.");
throw new HTTPException (error) ;
}
} catch (IOException ex) {
throw new ClientException(request.getClient(), ex);
}
// We do not support (for the time being) put with ranges:
if ( request.hasContentRange() ) {
Reply error = request.makeReply(HTTP.BAD_REQUEST);
error.setContent("partial PUT not supported.");
throw new HTTPException(error);
}
// Check that if some type is provided it doesn't conflict:
if ( request.hasContentType() ) {
MimeType rtype = request.getContentType() ;
MimeType type = getCommentType() ;
if ( type == null ) {
setValue (ATTR_CONTENT_TYPE, rtype) ;
} else if ( rtype.match (type) < 0 ) {
if (debug) {
System.out.println("No match between: ["+
rtype.toString()+"] and ["+
type.toString()+"]");
}
Reply error = request.makeReply(HTTP.UNSUPPORTED_MEDIA_TYPE) ;
error.setContent ("<p>Invalid content type: "+type.toString());
throw new HTTPException (error) ;
}
}
ImageFileResource ifresource = (ImageFileResource) fresource;
// Write the body back to the file:
try {
// We are about to accept the put, notify client before continuing
Client client = request.getClient();
if ( client != null && request.getExpect() != null ) {
client.sendContinue();
}
if ( ifresource.newMetadataContent(request.getInputStream()) )
status = HTTP.CREATED;
else
status = HTTP.NO_CONTENT;
} catch (IOException ex) {
throw new ClientException(request.getClient(), ex);
}
if ( status == HTTP.CREATED ) {
reply = createCommentReply(request, status);
reply.setContent("<P>Resource succesfully created");
if (request.hasState(STATE_CONTENT_LOCATION))