Renamed FileSearch class and defined default values
This commit is contained in:
parent
e2e6a40ce9
commit
997ec1c52b
8 changed files with 286 additions and 280 deletions
|
|
@ -219,7 +219,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
service.setExpirationTime(
|
||||
System.currentTimeMillis() + 1000 * getCacheTime(header.getHeader("Cache-Control")));
|
||||
}
|
||||
service.setHeaders(header.getHeaders());
|
||||
service.readHeaders(header);
|
||||
|
||||
if(listener != null && newService)
|
||||
listener.newService(service);
|
||||
|
|
|
|||
5
src/zutil/net/ssdp/SSDPCustomInfo.java
Normal file → Executable file
5
src/zutil/net/ssdp/SSDPCustomInfo.java
Normal file → Executable file
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package zutil.net.ssdp;
|
||||
|
||||
import zutil.net.http.HttpHeaderParser;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
|
||||
/**
|
||||
|
|
@ -31,5 +32,7 @@ import zutil.net.http.HttpPrintStream;
|
|||
*/
|
||||
public interface SSDPCustomInfo extends SSDPServiceInfo{
|
||||
|
||||
public void setHeaders(HttpPrintStream http);
|
||||
public void readHeaders(HttpHeaderParser http);
|
||||
|
||||
public void writeHeaders(HttpPrintStream http);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ public class SSDPServer extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
http.setHeader("EXT", "" );
|
||||
http.setHeader("Cache-Control", "max-age = "+ cache_time );
|
||||
if(services.get(st) instanceof SSDPCustomInfo)
|
||||
((SSDPCustomInfo)services.get(st)).setHeaders(http);
|
||||
((SSDPCustomInfo)services.get(st)).writeHeaders(http);
|
||||
logger.log(Level.FINEST, "Sending Response: "+ http);
|
||||
http.flush();
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ public class SSDPServer extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
http.setHeader("Cache-Control", "max-age = "+cache_time );
|
||||
http.setHeader("USN", service.getUSN() );
|
||||
if(service instanceof SSDPCustomInfo)
|
||||
((SSDPCustomInfo) service).setHeaders(http);
|
||||
((SSDPCustomInfo) service).writeHeaders(http);
|
||||
logger.log(Level.FINEST, "Sending Notification: " + http);
|
||||
http.flush();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package zutil.net.ssdp;
|
||||
|
||||
import zutil.net.http.HttpHeaderParser;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -44,7 +45,7 @@ public class StandardSSDPInfo implements SSDPServiceInfo, SSDPCustomInfo{
|
|||
private String usn;
|
||||
private long expiration_time;
|
||||
// All header parameters
|
||||
private HashMap<String, String> headers;
|
||||
private HashMap<String, String> headers = new HashMap<>();
|
||||
private InetAddress inetAddress;
|
||||
|
||||
/**
|
||||
|
|
@ -127,27 +128,28 @@ public class StandardSSDPInfo implements SSDPServiceInfo, SSDPCustomInfo{
|
|||
return "USN: "+usn+"\nLocation: "+location+"\nST: "+st+"\nExpiration-Time: "+new Date(expiration_time);
|
||||
}
|
||||
|
||||
public void setHeaders(HashMap<String, String> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public void setHeader(String key, String value) {
|
||||
headers.put(key, value);
|
||||
}
|
||||
public String getHeader(String header){
|
||||
return headers.get(header.toUpperCase());
|
||||
return headers.get(header);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setHeaders(HttpPrintStream http) {
|
||||
public void writeHeaders(HttpPrintStream http) {
|
||||
try {
|
||||
if (headers != null) {
|
||||
for (String key : headers.keySet()) {
|
||||
http.setHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
for (String key : headers.keySet())
|
||||
http.setHeader(key, headers.get(key));
|
||||
}catch(IOException e){
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void readHeaders(HttpHeaderParser http) {
|
||||
HashMap<String,String> httpHeaders = http.getHeaders();
|
||||
for (String key : httpHeaders.keySet())
|
||||
headers.put(key, httpHeaders.get(key));
|
||||
}
|
||||
|
||||
public InetAddress getInetAddress(){
|
||||
return inetAddress;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue