Skip to content

Commit

Permalink
added QName to make sardine running on android 2.1, added abort method
Browse files Browse the repository at this point in the history
  • Loading branch information
aflx committed Feb 20, 2012
1 parent 87cd7f6 commit 2212951
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 12 deletions.
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# project structure.

# Project target.
target=android-8
target=android-7
android.library=true
3 changes: 2 additions & 1 deletion src/de/aflx/sardine/DavResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import java.util.List;
import java.util.Map;

import javax.xml.namespace.QName;
//import javax.xml.namespace.QName;
import de.aflx.sardine.util.QName;

import org.w3c.dom.Element;

Expand Down
8 changes: 5 additions & 3 deletions src/de/aflx/sardine/Sardine.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.aflx.sardine;

import javax.xml.namespace.QName;
//import javax.xml.namespace.QName;
import de.aflx.sardine.impl.io.ConsumingInputStream;
import de.aflx.sardine.util.QName;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
Expand Down Expand Up @@ -89,7 +91,7 @@ public interface Sardine
* @return Data stream to read from
* @throws IOException I/O error or HTTP response validation failure
*/
InputStream get(String url) throws IOException;
ConsumingInputStream get(String url) throws IOException;

/**
* Uses HTTP <code>GET</code> to download data from a server. The stream must be closed after reading.
Expand All @@ -99,7 +101,7 @@ public interface Sardine
* @return Data stream to read from
* @throws IOException I/O error or HTTP response validation failure
*/
InputStream get(String url, Map<String, String> headers) throws IOException;
ConsumingInputStream get(String url, Map<String, String> headers) throws IOException;

/**
* Uses HTTP <code>PUT</code> to send data to a server. Repeatable on authentication failure.
Expand Down
7 changes: 4 additions & 3 deletions src/de/aflx/sardine/impl/SardineImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import java.util.List;
import java.util.Map;

import javax.xml.namespace.QName;
//import javax.xml.namespace.QName;
import de.aflx.sardine.util.QName;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
Expand Down Expand Up @@ -521,7 +522,7 @@ public void unlock(String url, String token) throws IOException {
*
* @see de.aflx.sardine.Sardine#get(java.lang.String)
*/
public InputStream get(String url) throws IOException {
public ConsumingInputStream get(String url) throws IOException {
return this.get(url, Collections.<String, String> emptyMap());
}

Expand All @@ -530,7 +531,7 @@ public InputStream get(String url) throws IOException {
*
* @see de.aflx.sardine.Sardine#get(java.lang.String, java.util.Map)
*/
public InputStream get(String url, Map<String, String> headers)
public ConsumingInputStream get(String url, Map<String, String> headers)
throws IOException {
HttpGet get = new HttpGet(url);
for (String header : headers.keySet()) {
Expand Down
5 changes: 4 additions & 1 deletion src/de/aflx/sardine/impl/io/ConsumingInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -47,6 +46,10 @@ public ConsumingInputStream(final HttpResponse response) throws IOException
this.delegate = entity.getContent();
}

public long getContentLength() {
return this.response.getEntity().getContentLength();
}

@Override
public int read(byte[] b) throws IOException
{
Expand Down
3 changes: 2 additions & 1 deletion src/de/aflx/sardine/model/ObjectFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
//import javax.xml.bind.JAXBElement;
//import javax.xml.bind.annotation.XmlElementDecl;
//import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
//import javax.xml.namespace.QName;
import de.aflx.sardine.util.QName;


/**
Expand Down
Loading

0 comments on commit 2212951

Please sign in to comment.