Code example for BasicHeader

0
                new ProtocolVersion("HTTP",1,1), 400, "Unauthorized"));
        InputStreamEntity inputStreamEntity = new InputStreamEntity(
                new ByteArrayInputStream(pushJSON.getBytes()),
                pushJSON.getBytes().length);
        httpResponse.setEntity(inputStreamEntity);
        httpResponse.setHeader(new BasicHeader(CONTENT_TYPE_KEY, CONTENT_TYPE_JSON));
        PushAPIResponseHandler handler = new PushAPIResponseHandler();
 
        try { 
            handler.handleResponse(httpResponse);
        } 
        catch (APIRequestException ex){
 
            APIError error = ex.getError().get();
            String errorMessage = error.getError();
            assertTrue("Error message incorrect", errorMessage.equals("Unauthorized"));
            return; 
        } 
        catch (Exception ex){
            fail("Failed with incorrect exception " + ex);
        }