use of org.jivesoftware.smackx.shim.packet.HeadersExtension in project Smack by igniterealtime.
the class HeadersProviderTest method headersInMessageTest.
@Test
public void headersInMessageTest() throws Exception {
// @formatter:off
final String messageStanza = "<message from='romeo@shakespeare.lit/orchard' to='juliet@capulet.com' type='chat'>" + "<body>Wherefore are thou?!?</body>" + "<headers xmlns='http://jabber.org/protocol/shim'>" + "<header name='Urgency'>high</header>" + "</headers>" + "</message>";
// @formatter:on
XmlPullParser parser = TestUtils.getMessageParser(messageStanza);
Message message = PacketParserUtils.parseMessage(parser);
HeadersExtension headers = HeadersExtension.from(message);
Header header = headers.getHeaders().get(0);
assertEquals("Urgency", header.getName());
assertEquals("high", header.getValue());
}
use of org.jivesoftware.smackx.shim.packet.HeadersExtension in project Smack by igniterealtime.
the class AbstractHttpOverXmppProvider method parseHeaders.
/**
* Parses HeadersExtension element if any.
*
* @param parser parser
* @return HeadersExtension or null if no headers
* @throws Exception
*/
protected HeadersExtension parseHeaders(XmlPullParser parser) throws Exception {
HeadersExtension headersExtension = null;
/* We are either at start of headers, start of data or end of req/res */
if (parser.next() == XmlPullParser.START_TAG && parser.getName().equals(HeadersExtension.ELEMENT)) {
headersExtension = HeadersProvider.INSTANCE.parse(parser);
parser.next();
}
return headersExtension;
}
use of org.jivesoftware.smackx.shim.packet.HeadersExtension in project Smack by igniterealtime.
the class HttpOverXmppRespProvider method parse.
@Override
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth) throws Exception {
String version = parser.getAttributeValue("", ATTRIBUTE_VERSION);
String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE);
String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE);
int statusCode = Integer.parseInt(statusCodeString);
HeadersExtension headers = parseHeaders(parser);
AbstractHttpOverXmpp.Data data = parseData(parser);
return HttpOverXmppResp.builder().setHeaders(headers).setData(data).setStatusCode(statusCode).setStatusMessage(statusMessage).setVersion(version).build();
}
use of org.jivesoftware.smackx.shim.packet.HeadersExtension in project Smack by igniterealtime.
the class Node method getSubscriptionIds.
private static List<String> getSubscriptionIds(Stanza packet) {
HeadersExtension headers = (HeadersExtension) packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null;
if (headers != null) {
values = new ArrayList<String>(headers.getHeaders().size());
for (Header header : headers.getHeaders()) {
values.add(header.getValue());
}
}
return values;
}
Aggregations