Replacement for drupal_add_http_header() I have a custom module which are basically APIs, hence require headers like content-type to be added to the responses. I was using drupal_add_http_header() in Drupal 7, but it seems to be deprecated in 8. Is there any replacement?

I did read about it on the Drupal website talking about Symfony object Response, but I am unable to use that either.
If you want to modify the headers of a response, you need to use an EventSubscriber. Symphony doesn't have a hook system, but instead uses an event/emitter system. Since it's Symphony driving the request/response cycle, you basically needs to integrate with Symphony to do this.

You could take a look at \Drupal\Core\EventSubscriber\FinishResponseSubscriber to see how this is done, the gist of it is this:

/**
 * Add custom headers.
 */
class HeaderResponseSubscriber implements EventSubscriberInterface {
  public function onRespond(FilterResponseEvent $event) {
    $response = $event-&gt;getResponse();
    $response-&gt;headers-&gt;set('Some-Header', 'some value'); 
  }

  public static function getSubscribedEvents() {
    $events[KernelEvents::RESPONSE][] = array('onRespond');
    return $events;
  }
}


Note in the above code all use statements have been excluded, also you need to register your class as a event_subscriber service, this is done in your module's module_name.services.yml file like this:

services:
  name_of_service:
    class: Drupal\Full\Namespaced\Path\To\Class
    tags:
      - { name: event_subscriber }


You can add arguments (other services) that your class will depend on in the services file like normally.