mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +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 ELEMENT = "request";
|
||||||
public static final String NAMESPACE = HttpFileUploadManager.NAMESPACE;
|
public static final String NAMESPACE = HttpFileUploadManager.NAMESPACE;
|
||||||
|
|
||||||
private final String filename;
|
protected final String filename;
|
||||||
private final long size;
|
protected final long size;
|
||||||
private final String contentType;
|
protected final String contentType;
|
||||||
|
|
||||||
public SlotRequest(DomainBareJid uploadServiceAddress, String filename, long size) {
|
public SlotRequest(DomainBareJid uploadServiceAddress, String filename, long size) {
|
||||||
this(uploadServiceAddress, filename, size, null);
|
this(uploadServiceAddress, filename, size, null);
|
||||||
|
@ -82,10 +82,10 @@ public class SlotRequest extends IQ {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
xml.rightAngleBracket();
|
xml.attribute("filename", filename);
|
||||||
xml.element("filename", filename);
|
xml.attribute("size", String.valueOf(size));
|
||||||
xml.element("size", String.valueOf(size));
|
xml.optAttribute("content-type", contentType);
|
||||||
xml.optElement("content-type", contentType);
|
xml.setEmptyElement();
|
||||||
return xml;
|
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) {
|
public SlotRequest_V0_2(DomainBareJid uploadServiceAddress, String filename, long size, String contentType) {
|
||||||
super(uploadServiceAddress, filename, size, contentType, NAMESPACE);
|
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 {
|
public class SlotRequestCreateTest {
|
||||||
|
|
||||||
String testRequest
|
String testRequest
|
||||||
= "<request xmlns='urn:xmpp:http:upload:0'>"
|
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||||
+ "<filename>my_juliet.png</filename>"
|
+ " filename='my_juliet.png'"
|
||||||
+ "<size>23456</size>"
|
+ " size='23456'"
|
||||||
+ "<content-type>image/jpeg</content-type>"
|
+ " content-type='image/jpeg'"
|
||||||
+ "</request>";
|
+ "/>";
|
||||||
|
|
||||||
String testRequestWithoutContentType
|
String testRequestWithoutContentType
|
||||||
= "<request xmlns='urn:xmpp:http:upload:0'>"
|
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||||
+ "<filename>my_romeo.png</filename>"
|
+ " filename='my_romeo.png'"
|
||||||
+ "<size>52523</size>"
|
+ " size='52523'"
|
||||||
+ "</request>";
|
+ "/>";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkSlotRequestCreation() throws XmppStringprepException {
|
public void checkSlotRequestCreation() throws XmppStringprepException {
|
||||||
|
|
Loading…
Reference in a new issue