protected SubscriptionSummary postNotification(final Subscriber subscriber, final String mimeType, final byte[] payload) {
        final SubscriptionSummary result = new SubscriptionSummary();

        try {
            final URL target = new URL(subscriber.getCallback());
            LOG.info("Posting notification to subscriber {}", subscriber.getCallback());
            result.setHost(target.getHost());

            final HttpURLConnection connection = (HttpURLConnection) target.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", mimeType);
            connection.setDoOutput(true);
            connection.connect();

            final OutputStream os = connection.getOutputStream();
            os.write(payload);
            os.close();

            final int responseCode = connection.getResponseCode();
            final String subscribers = connection.getHeaderField("X-Hub-On-Behalf-Of");
            connection.disconnect();

            if (responseCode != 200) {
                LOG.warn("Got code {} from {}", responseCode, target);
                result.setLastPublishSuccessful(false);
                return result;
            }

            if (subscribers != null) {
                try {
                    result.setSubscribers(Integer.parseInt(subscribers));
                } catch (final NumberFormatException nfe) {
                    LOG.warn("Invalid subscriber value " + subscribers + " " + target, nfe);
                    result.setSubscribers(-1);
                }
            } else {
                result.setSubscribers(-1);
            }
        } catch (final MalformedURLException ex) {
            LOG.warn(null, ex);
            result.setLastPublishSuccessful(false);
        } catch (final IOException ex) {
            LOG.error(null, ex);
            result.setLastPublishSuccessful(false);
        }

        return result;
    }
protected SubscriptionSummary postNotification ( final Subscriber subscriber , final String mimeType , final byte [ ] payload ) { final SubscriptionSummary result = new SubscriptionSummary ( ) ; try { final URL target = new URL ( subscriber . getCallback ( ) ) ; LOG . info ( "Posting notification to subscriber {}" , subscriber . getCallback ( ) ) ; result . setHost ( target . getHost ( ) ) ; final HttpURLConnection connection = ( HttpURLConnection ) target . openConnection ( ) ; connection . setRequestMethod ( "POST" ) ; connection . setRequestProperty ( "Content-Type" , mimeType ) ; connection . setDoOutput ( true ) ; connection . connect ( ) ; final OutputStream os = connection . getOutputStream ( ) ; os . write ( payload ) ; os . close ( ) ; final int responseCode = connection . getResponseCode ( ) ; final String subscribers = connection . getHeaderField ( "X-Hub-On-Behalf-Of" ) ; connection . disconnect ( ) ; if ( responseCode != 200 ) { LOG . warn ( "Got code {} from {}" , responseCode , target ) ; result . setLastPublishSuccessful ( false ) ; return result ; } if ( subscribers != null ) { try { result . setSubscribers ( Integer . parseInt ( subscribers ) ) ; } catch ( final NumberFormatException nfe ) { LOG . warn ( "Invalid subscriber value " + subscribers + " " + target , nfe ) ; result . setSubscribers ( - 1 ) ; } } else { result . setSubscribers ( - 1 ) ; } } catch ( final MalformedURLException ex ) { LOG . warn ( null , ex ) ; result . setLastPublishSuccessful ( false ) ; } catch ( final IOException ex ) { LOG . error ( null , ex ) ; result . setLastPublishSuccessful ( false ) ; } return result ; }
POSTs the payload to the subscriber's callback and returns a SubscriptionSummary with
subscriber counts (where possible) and the success state of the notification.

@param subscriber subscriber data.
@param mimeType MIME type for the request
@param payload payload of the feed to send
@return SubscriptionSummary with the returned data.