2016-04-13 12 views
0
String url = "some_url"; 
    HttpClient httpClient = new HttpClient(); 
    httpClient.start(); 
    Map<String, Object> options = new HashMap<String, Object>(); 
    LongPollingTransport transport = new LongPollingTransport(options, httpClient); 
    BayeuxClient client = new BayeuxClient(url, transport); 
    client.getChannel(Channel.META_HANDSHAKE).addListener(new ClientSessionChannel.MessageListener() { 
    public void onMessage(ClientSessionChannel channel, Message message) { 
     System.out.println(message); 
    } 
    }); 
    client.handshake(); 

ПолучениеКак добавить заголовок запроса к BayeuxClient

{"failure":{"exception":"org.cometd.common.TransportException: {httpCode=403}","message":{"supportedConnectionTypes":["long-polling"],"channel":"/meta/handshake","id":"2","version":"1.0"},"httpCode":403,"connectionType":"long-polling"},"channel":"/meta/handshake","id":"2","subscription":null,"successful":false} 

Итак, моя первая догадка добавить заголовок авторизации. Как я могу это сделать? Jetty 9 используется как для серверных, так и для клиентских кодовых библиотек.

ответ