Departamento de Informática - Arquitectura de Sistemas ...
Departamento de Informática - Arquitectura de Sistemas ...
Departamento de Informática - Arquitectura de Sistemas ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
ANEXO A<br />
/** Servidor HTTP seguro.<br />
*/<br />
public class HttpsServer<br />
{<br />
private int port;<br />
HttpsServer( int port) {<br />
this.port = port;<br />
}<br />
/**<br />
* Devolve um stream para o recurso referido num dado pedido http<br />
* (in<strong>de</strong>pen<strong>de</strong>ntemente <strong>de</strong> se tratar <strong>de</strong> uma página estática ou dinâmica).<br />
* Caso o recurso não exista, o stream contém o conteúdo da mensagem<br />
* <strong>de</strong> erro apropriada.<br />
*<br />
* @param pedidoHTTP Linha completa <strong>de</strong> um pedido HTTP (ex. GET /in<strong>de</strong>x.html)<br />
*/<br />
public static InputStream obtemRecurso( String pedidoHTTP) {...}<br />
/**<br />
* Inicia o servidor <strong>de</strong> https (ex. HttpsServer port_num).<br />
*/<br />
public static void main( String[] args) {<br />
if( args.length == 1) {<br />
HttpsServer server = new HttpsServer(Integer.parseInt( args[0]));<br />
server.run();<br />
}<br />
}<br />
/**<br />
* Função principal do servidor. As excepções ocorridas numa conexão não<br />
* <strong>de</strong>vem fazer com que o servidor conclua a sua execução.<br />
*/<br />
private void run() throws Exception {<br />
}<br />
}<br />
4