The High Court has rejected a claim by David Miranda, the partner of a former Guardian journalist, that he was unlawfully detained when he was held for nine hours at Heathrow Airport.