mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-24 03:27:59 +01:00
Fix HTTP File Upload's SlotRequest
Fixes SMACK-774. Thanks to Nathan Freitas for reporting this.
This commit is contained in:
parent
e87c463927
commit
858ba3f82a
3 changed files with 25 additions and 16 deletions
|
@ -32,9 +32,9 @@ public class SlotRequest extends IQ {
|
|||
public static final String ELEMENT = "request";
|
||||
public static final String NAMESPACE = HttpFileUploadManager.NAMESPACE;
|
||||
|
||||
private final String filename;
|
||||
private final long size;
|
||||
private final String contentType;
|
||||
protected final String filename;
|
||||
protected final long size;
|
||||
protected final String contentType;
|
||||
|
||||
public SlotRequest(DomainBareJid uploadServiceAddress, String filename, long size) {
|
||||
this(uploadServiceAddress, filename, size, null);
|
||||
|
@ -82,10 +82,10 @@ public class SlotRequest extends IQ {
|
|||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.element("filename", filename);
|
||||
xml.element("size", String.valueOf(size));
|
||||
xml.optElement("content-type", contentType);
|
||||
xml.attribute("filename", filename);
|
||||
xml.attribute("size", String.valueOf(size));
|
||||
xml.optAttribute("content-type", contentType);
|
||||
xml.setEmptyElement();
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,13 @@ public class SlotRequest_V0_2 extends SlotRequest {
|
|||
public SlotRequest_V0_2(DomainBareJid uploadServiceAddress, String filename, long size, String contentType) {
|
||||
super(uploadServiceAddress, filename, size, contentType, NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.element("filename", filename);
|
||||
xml.element("size", String.valueOf(size));
|
||||
xml.optElement("content-type", contentType);
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,17 +27,17 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
|||
public class SlotRequestCreateTest {
|
||||
|
||||
String testRequest
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<filename>my_juliet.png</filename>"
|
||||
+ "<size>23456</size>"
|
||||
+ "<content-type>image/jpeg</content-type>"
|
||||
+ "</request>";
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||
+ " filename='my_juliet.png'"
|
||||
+ " size='23456'"
|
||||
+ " content-type='image/jpeg'"
|
||||
+ "/>";
|
||||
|
||||
String testRequestWithoutContentType
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<filename>my_romeo.png</filename>"
|
||||
+ "<size>52523</size>"
|
||||
+ "</request>";
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||
+ " filename='my_romeo.png'"
|
||||
+ " size='52523'"
|
||||
+ "/>";
|
||||
|
||||
@Test
|
||||
public void checkSlotRequestCreation() throws XmppStringprepException {
|
||||
|
|
Loading…
Reference in a new issue