reqEntity.setContentType(WebContent.contentTypeRDFXML) ;
reqEntity.setContentEncoding(WebContent.charsetUTF8) ;
HttpEntity entity = reqEntity ;
((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ;
}
TypedInputStream ts = null ;
// httpclient.getParams().setXXX
try {
HttpResponse response = httpclient.execute(httpRequest) ;
int responseCode = response.getStatusLine().getStatusCode() ;
String responseMessage = response.getStatusLine().getReasonPhrase() ;
if ( HttpSC.isRedirection(responseCode) )
// Not implemented yet.
throw FusekiRequestException.create(responseCode, responseMessage) ;
// Other 400 and 500 - errors
if ( HttpSC.isClientError(responseCode) || HttpSC.isServerError(responseCode) )
throw FusekiRequestException.create(responseCode, responseMessage) ;
if ( responseCode == HttpSC.NO_CONTENT_204) return null ;
if ( responseCode == HttpSC.CREATED_201 ) return null ;
if ( responseCode != HttpSC.OK_200 )
{
Log.warn(this, "Unexpected status code") ;
throw FusekiRequestException.create(responseCode, responseMessage) ;
}
// May not have a body.
String ct = getHeader(response, HttpNames.hContentType) ;
if ( ct == null )
{
HttpEntity entity = response.getEntity() ;
if (entity != null)
{
InputStream instream = entity.getContent() ;
// Read to completion?
instream.close() ;
}
return null ;
}
// Tidy. See ConNeg / MediaType.
String x = getHeader(response, HttpNames.hContentType) ;
String y[] = x.split(";") ;
String contentType = null ;
if ( y[0] != null )
contentType = y[0].trim();
String charset = null ;
if ( y.length > 1 && y[1] != null )
charset = y[1].trim();
// Get hold of the response entity
HttpEntity entity = response.getEntity() ;
if (entity != null)
{
InputStream instream = entity.getContent() ;
// String mimeType = ConNeg.chooseContentType(request, rdfOffer, ConNeg.acceptRDFXML).getAcceptType() ;
// String charset = ConNeg.chooseCharset(request, charsetOffer, ConNeg.charsetUTF8).getAcceptType() ;
ts = new TypedInputStream(instream, contentType, charset, null) ;
}
Graph graph = GraphFactory.createGraphMem() ;
if ( processBody )
readGraph(graph, ts, null) ;
if ( ts != null )
ts.close() ;
Graph graph2 = new UnmodifiableGraph(graph) ;
return graph2 ;
} catch (IOException ex)
{
httpRequest.abort() ;