mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-27 00:47:48 +01:00
Fix messed up indentation in StreamProxy
This commit is contained in:
parent
9acc5121a4
commit
f4554ff29e
@ -1,7 +1,5 @@
|
|||||||
package org.moire.ultrasonic.util;
|
package org.moire.ultrasonic.util;
|
||||||
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
import org.moire.ultrasonic.domain.MusicDirectory;
|
import org.moire.ultrasonic.domain.MusicDirectory;
|
||||||
import org.moire.ultrasonic.service.DownloadFile;
|
import org.moire.ultrasonic.service.DownloadFile;
|
||||||
import org.moire.ultrasonic.service.Supplier;
|
import org.moire.ultrasonic.service.Supplier;
|
||||||
@ -22,6 +20,8 @@ import java.net.URLDecoder;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class StreamProxy implements Runnable
|
public class StreamProxy implements Runnable
|
||||||
{
|
{
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
@ -101,58 +101,58 @@ public class StreamProxy implements Runnable
|
|||||||
Timber.i("Proxy interrupted. Shutting down.");
|
Timber.i("Proxy interrupted. Shutting down.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StreamToMediaPlayerTask implements Runnable {
|
private class StreamToMediaPlayerTask implements Runnable {
|
||||||
String localPath;
|
String localPath;
|
||||||
Socket client;
|
Socket client;
|
||||||
int cbSkip;
|
int cbSkip;
|
||||||
|
|
||||||
StreamToMediaPlayerTask(Socket client) {
|
StreamToMediaPlayerTask(Socket client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readRequest() {
|
private String readRequest() {
|
||||||
InputStream is;
|
InputStream is;
|
||||||
String firstLine;
|
String firstLine;
|
||||||
try {
|
try {
|
||||||
is = client.getInputStream();
|
is = client.getInputStream();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8192);
|
BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8192);
|
||||||
firstLine = reader.readLine();
|
firstLine = reader.readLine();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Timber.e(e, "Error parsing request");
|
Timber.e(e, "Error parsing request");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstLine == null) {
|
if (firstLine == null) {
|
||||||
Timber.i("Proxy client closed connection without a request.");
|
Timber.i("Proxy client closed connection without a request.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTokenizer st = new StringTokenizer(firstLine);
|
StringTokenizer st = new StringTokenizer(firstLine);
|
||||||
st.nextToken(); // method
|
st.nextToken(); // method
|
||||||
String uri = st.nextToken();
|
String uri = st.nextToken();
|
||||||
String realUri = uri.substring(1);
|
String realUri = uri.substring(1);
|
||||||
Timber.i(realUri);
|
Timber.i(realUri);
|
||||||
|
|
||||||
return realUri;
|
return realUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean processRequest() {
|
boolean processRequest() {
|
||||||
final String uri = readRequest();
|
final String uri = readRequest();
|
||||||
if (uri == null || uri.isEmpty()) {
|
if (uri == null || uri.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read HTTP headers
|
// Read HTTP headers
|
||||||
Timber.i("Processing request: %s", uri);
|
Timber.i("Processing request: %s", uri);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
localPath = URLDecoder.decode(uri, Constants.UTF_8);
|
localPath = URLDecoder.decode(uri, Constants.UTF_8);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Timber.e(e, "Unsupported encoding");
|
Timber.e(e, "Unsupported encoding");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.i("Processing request for file %s", localPath);
|
Timber.i("Processing request for file %s", localPath);
|
||||||
if (Storage.INSTANCE.isPathExists(localPath)) return true;
|
if (Storage.INSTANCE.isPathExists(localPath)) return true;
|
||||||
|
|
||||||
// Usually the .partial file will be requested here, but sometimes it has already
|
// Usually the .partial file will be requested here, but sometimes it has already
|
||||||
|
Loading…
x
Reference in New Issue
Block a user