Changed HttpPrintStream to use a internal stream instead of extending one
This commit is contained in:
parent
a199165756
commit
1684c86a60
13 changed files with 130 additions and 119 deletions
|
|
@ -104,10 +104,9 @@ public class HttpClient {
|
||||||
request.setHeader("Content-Length", data);
|
request.setHeader("Content-Length", data);
|
||||||
request.println();
|
request.println();
|
||||||
request.print( data );
|
request.print( data );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
request.println("");
|
request.println();
|
||||||
request.close();
|
request.close();
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
package zutil.net.http;
|
package zutil.net.http;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,5 +46,5 @@ public interface HttpPage{
|
||||||
HttpHeaderParser client_info,
|
HttpHeaderParser client_info,
|
||||||
Map<String,Object> session,
|
Map<String,Object> session,
|
||||||
Map<String,String> cookie,
|
Map<String,String> cookie,
|
||||||
Map<String,String> request);
|
Map<String,String> request) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@
|
||||||
|
|
||||||
package zutil.net.http;
|
package zutil.net.http;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.*;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,13 +32,15 @@ import java.util.HashMap;
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class HttpPrintStream extends PrintStream{
|
public class HttpPrintStream extends OutputStream{
|
||||||
// Defines the type of message
|
// Defines the type of message
|
||||||
public enum HttpMessageType{
|
public enum HttpMessageType{
|
||||||
REQUEST,
|
REQUEST,
|
||||||
RESPONSE
|
RESPONSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The actual output stream
|
||||||
|
private PrintStream out;
|
||||||
// This defines the type of message that will be generated
|
// This defines the type of message that will be generated
|
||||||
private HttpMessageType message_type;
|
private HttpMessageType message_type;
|
||||||
// The status code of the message, ONLY for response
|
// The status code of the message, ONLY for response
|
||||||
|
|
@ -74,14 +75,13 @@ public class HttpPrintStream extends PrintStream{
|
||||||
* @param type is the type of message
|
* @param type is the type of message
|
||||||
*/
|
*/
|
||||||
public HttpPrintStream(OutputStream out, HttpMessageType type) {
|
public HttpPrintStream(OutputStream out, HttpMessageType type) {
|
||||||
super(out);
|
this.out = new PrintStream(out);
|
||||||
|
|
||||||
this.message_type = type;
|
this.message_type = type;
|
||||||
res_status_code = 0;
|
this.res_status_code = 0;
|
||||||
headers = new HashMap<String, String>();
|
this.headers = new HashMap<String, String>();
|
||||||
cookies = new HashMap<String, String>();
|
this.cookies = new HashMap<String, String>();
|
||||||
buffer = new StringBuffer();
|
this.buffer = new StringBuffer();
|
||||||
buffer_enabled = false;
|
this.buffer_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -93,7 +93,7 @@ public class HttpPrintStream extends PrintStream{
|
||||||
*
|
*
|
||||||
* @param b
|
* @param b
|
||||||
*/
|
*/
|
||||||
public void enableBuffering(boolean b){
|
public void enableBuffering(boolean b) throws IOException {
|
||||||
buffer_enabled = b;
|
buffer_enabled = b;
|
||||||
if(!buffer_enabled) flush();
|
if(!buffer_enabled) flush();
|
||||||
}
|
}
|
||||||
|
|
@ -103,11 +103,11 @@ public class HttpPrintStream extends PrintStream{
|
||||||
*
|
*
|
||||||
* @param key is the name of the cookie
|
* @param key is the name of the cookie
|
||||||
* @param value is the value of the cookie
|
* @param value is the value of the cookie
|
||||||
* @throws Exception Throws exception if the header has already been sent
|
* @throws IOException Throws exception if the header has already been sent
|
||||||
*/
|
*/
|
||||||
public void setCookie(String key, String value) throws RuntimeException{
|
public void setCookie(String key, String value) throws IOException{
|
||||||
if(cookies == null)
|
if(cookies == null)
|
||||||
throw new RuntimeException("Header already sent!!!");
|
throw new IOException("Header already sent!");
|
||||||
cookies.put(key, value);
|
cookies.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,11 +116,11 @@ public class HttpPrintStream extends PrintStream{
|
||||||
*
|
*
|
||||||
* @param key is the header name
|
* @param key is the header name
|
||||||
* @param value is the value of the header
|
* @param value is the value of the header
|
||||||
* @throws Exception Throws exception if the header has already been sent
|
* @throws IOException Throws exception if the header has already been sent
|
||||||
*/
|
*/
|
||||||
public void setHeader(String key, String value) throws RuntimeException{
|
public void setHeader(String key, String value) throws IOException{
|
||||||
if(headers == null)
|
if(headers == null)
|
||||||
throw new RuntimeException("Header already sent!!!");
|
throw new IOException("Header already sent!");
|
||||||
headers.put(key, value);
|
headers.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,13 +128,13 @@ public class HttpPrintStream extends PrintStream{
|
||||||
* Sets the status code of the message, ONLY available in HTTP RESPONSE
|
* Sets the status code of the message, ONLY available in HTTP RESPONSE
|
||||||
*
|
*
|
||||||
* @param code the code from 100 up to 599
|
* @param code the code from 100 up to 599
|
||||||
* @throws RuntimeException if the header has already been sent or the message type is wrong
|
* @throws IOException if the header has already been sent or the message type is wrong
|
||||||
*/
|
*/
|
||||||
public void setStatusCode(int code) throws RuntimeException{
|
public void setStatusCode(int code) throws IOException{
|
||||||
if( res_status_code == null )
|
if( res_status_code == null )
|
||||||
throw new RuntimeException("Header already sent!!!");
|
throw new IOException("Header already sent!");
|
||||||
if( message_type != HttpMessageType.RESPONSE )
|
if( message_type != HttpMessageType.RESPONSE )
|
||||||
throw new RuntimeException("Status Code is only available in HTTP RESPONSE!!!");
|
throw new IOException("Status Code is only available in HTTP RESPONSE!");
|
||||||
res_status_code = code;
|
res_status_code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,26 +142,26 @@ public class HttpPrintStream extends PrintStream{
|
||||||
* Sets the request type of the message, ONLY available in HTTP REQUEST
|
* Sets the request type of the message, ONLY available in HTTP REQUEST
|
||||||
*
|
*
|
||||||
* @param req_type is the type of the message, e.g. GET, POST...
|
* @param req_type is the type of the message, e.g. GET, POST...
|
||||||
* @throws RuntimeException if the header has already been sent or the message type is wrong
|
* @throws IOException if the header has already been sent or the message type is wrong
|
||||||
*/
|
*/
|
||||||
public void setRequestType(String req_type) throws RuntimeException{
|
public void setRequestType(String req_type) throws IOException{
|
||||||
if( req_type == null )
|
if( req_type == null )
|
||||||
throw new RuntimeException("Header already sent!!!");
|
throw new IOException("Header already sent!");
|
||||||
if( message_type != HttpMessageType.REQUEST )
|
if( message_type != HttpMessageType.REQUEST )
|
||||||
throw new RuntimeException("Request Message Type is only available in HTTP REQUEST!!!");
|
throw new IOException("Request Message Type is only available in HTTP REQUEST!");
|
||||||
this.req_type = req_type;
|
this.req_type = req_type;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets the requesting URL of the message, ONLY available in HTTP REQUEST
|
* Sets the requesting URL of the message, ONLY available in HTTP REQUEST
|
||||||
*
|
*
|
||||||
* @param req_url is the URL
|
* @param req_url is the URL
|
||||||
* @throws RuntimeException if the header has already been sent or the message type is wrong
|
* @throws IOException if the header has already been sent or the message type is wrong
|
||||||
*/
|
*/
|
||||||
public void setRequestURL(String req_url) throws RuntimeException{
|
public void setRequestURL(String req_url) throws IOException{
|
||||||
if( req_url == null )
|
if( req_url == null )
|
||||||
throw new RuntimeException("Header already sent!!!");
|
throw new IOException("Header already sent!");
|
||||||
if( message_type != HttpMessageType.REQUEST )
|
if( message_type != HttpMessageType.REQUEST )
|
||||||
throw new RuntimeException("Request URL is only available in HTTP REQUEST!!!");
|
throw new IOException("Request URL is only available in HTTP REQUEST!");
|
||||||
this.req_url = req_url;
|
this.req_url = req_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,66 +171,71 @@ public class HttpPrintStream extends PrintStream{
|
||||||
protected void setCookies( HashMap<String,String> map ){
|
protected void setCookies( HashMap<String,String> map ){
|
||||||
cookies = map;
|
cookies = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a new line
|
||||||
|
*/
|
||||||
|
public void println() throws IOException {
|
||||||
|
printOrBuffer(System.lineSeparator());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Prints with a new line
|
* Prints with a new line
|
||||||
*/
|
*/
|
||||||
public void println(String s){
|
public void println(String s) throws IOException {
|
||||||
printOrBuffer(s+"\n");
|
printOrBuffer(s + System.lineSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints an string
|
* Prints an string
|
||||||
*/
|
*/
|
||||||
public void print(String s){
|
public void print(String s) throws IOException {
|
||||||
printOrBuffer(s);
|
printOrBuffer(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prints to all
|
* Will buffer String or directly output headers if needed and then the String
|
||||||
*/
|
*/
|
||||||
private void printOrBuffer(String s){
|
private void printOrBuffer(String s) throws IOException {
|
||||||
if(buffer_enabled){
|
if(buffer_enabled){
|
||||||
buffer.append(s);
|
buffer.append(s);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(res_status_code != null){
|
if(res_status_code != null){
|
||||||
if( message_type==HttpMessageType.REQUEST )
|
if( message_type==HttpMessageType.REQUEST )
|
||||||
super.print(req_type+" "+req_url+" HTTP/1.0");
|
out.print(req_type + " " + req_url + " HTTP/1.0");
|
||||||
else
|
else
|
||||||
super.print("HTTP/1.0 "+res_status_code+" "+getStatusString(res_status_code));
|
out.print("HTTP/1.0 " + res_status_code + " " + getStatusString(res_status_code));
|
||||||
super.print(System.lineSeparator());
|
out.println();
|
||||||
res_status_code = null;
|
res_status_code = null;
|
||||||
req_type = null;
|
req_type = null;
|
||||||
req_url = null;
|
req_url = null;
|
||||||
}
|
}
|
||||||
if(headers != null){
|
if(headers != null){
|
||||||
for(String key : headers.keySet()){
|
for(String key : headers.keySet()){
|
||||||
super.print(key+": "+headers.get(key));
|
out.println(key + ": " + headers.get(key));
|
||||||
super.print(System.lineSeparator());
|
|
||||||
}
|
}
|
||||||
headers = null;
|
headers = null;
|
||||||
}
|
}
|
||||||
if(cookies != null){
|
if(cookies != null){
|
||||||
if( !cookies.isEmpty() ){
|
if( !cookies.isEmpty() ){
|
||||||
if( message_type==HttpMessageType.REQUEST ){
|
if( message_type==HttpMessageType.REQUEST ){
|
||||||
super.print("Cookie: ");
|
out.print("Cookie: ");
|
||||||
for(String key : cookies.keySet()){
|
for(String key : cookies.keySet()){
|
||||||
super.print(key+"="+cookies.get(key)+"; ");
|
out.print(key + "=" + cookies.get(key) + "; ");
|
||||||
}
|
}
|
||||||
super.print(System.lineSeparator());
|
out.println();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
for(String key : cookies.keySet()){
|
for(String key : cookies.keySet()){
|
||||||
super.print("Set-Cookie: "+key+"="+cookies.get(key)+";");
|
out.print("Set-Cookie: " + key + "=" + cookies.get(key) + ";");
|
||||||
super.print(System.lineSeparator());
|
out.print(System.lineSeparator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.print(System.lineSeparator());
|
out.print(System.lineSeparator());
|
||||||
cookies = null;
|
cookies = null;
|
||||||
}
|
}
|
||||||
super.print(s);
|
out.print(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,14 +246,23 @@ public class HttpPrintStream extends PrintStream{
|
||||||
return res_status_code == null && headers == null && cookies == null;
|
return res_status_code == null && headers == null && cookies == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends out the buffer and clears it
|
* Sends out the buffer and clears it
|
||||||
*/
|
*/
|
||||||
public void flush(){
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
super.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
protected void flushBuffer(){
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void flushBuffer() throws IOException {
|
||||||
if(buffer_enabled){
|
if(buffer_enabled){
|
||||||
buffer_enabled = false;
|
buffer_enabled = false;
|
||||||
printOrBuffer(buffer.toString());
|
printOrBuffer(buffer.toString());
|
||||||
|
|
@ -260,40 +274,26 @@ public class HttpPrintStream extends PrintStream{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close(){
|
/**
|
||||||
flush();
|
* Will flush all buffers and write binary data to stream
|
||||||
super.close();
|
*/
|
||||||
|
@Override
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
flushBuffer();
|
||||||
|
out.write(b);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* * Will flush all buffers and write binary data to stream
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void write(byte[] buf, int off, int len) throws IOException {
|
||||||
|
flushBuffer();
|
||||||
|
out.write(buf, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rawWrite(String s) throws IOException {
|
||||||
public void print(boolean x){ printOrBuffer(String.valueOf(x));}
|
out.write(s.getBytes());
|
||||||
public void print(char x){ printOrBuffer(String.valueOf(x));}
|
|
||||||
public void print(char[] x){ printOrBuffer(new String(x));}
|
|
||||||
public void print(double x){ printOrBuffer(String.valueOf(x));}
|
|
||||||
public void print(float x){ printOrBuffer(String.valueOf(x));}
|
|
||||||
public void print(int x) { printOrBuffer(String.valueOf(x));}
|
|
||||||
public void print(long x){ printOrBuffer(String.valueOf(x));}
|
|
||||||
public void print(Object x){ printOrBuffer(String.valueOf(x));}
|
|
||||||
|
|
||||||
public void println(){ println("");}
|
|
||||||
public void println(boolean x){ println(String.valueOf(x));}
|
|
||||||
public void println(char x){ println(String.valueOf(x));}
|
|
||||||
public void println(char[] x){ println(new String(x));}
|
|
||||||
public void println(double x){ println(String.valueOf(x));}
|
|
||||||
public void println(float x) { println(String.valueOf(x));}
|
|
||||||
public void println(int x){ println(String.valueOf(x));}
|
|
||||||
public void println(long x){ println(String.valueOf(x));}
|
|
||||||
public void println(Object x){ println(String.valueOf(x));}
|
|
||||||
|
|
||||||
/* java.lang.StackOverflowError
|
|
||||||
public void write(int b) {
|
|
||||||
flushBuffer();
|
|
||||||
super.write(b);
|
|
||||||
}
|
}
|
||||||
public void write(byte buf[], int off, int len){
|
|
||||||
flushBuffer();
|
|
||||||
super.write(buf, off, len);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
private String getStatusString(int type){
|
private String getStatusString(int type){
|
||||||
switch(type){
|
switch(type){
|
||||||
|
|
|
||||||
|
|
@ -255,15 +255,18 @@ public class HttpServer extends ThreadedTCPNetworkServer{
|
||||||
//********************************************************************************
|
//********************************************************************************
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING, "500 Internal Server Error", e);
|
logger.log(Level.WARNING, "500 Internal Server Error", e);
|
||||||
if(!out.isHeaderSent())
|
try {
|
||||||
out.setStatusCode( 500 );
|
if (!out.isHeaderSent())
|
||||||
if(e.getMessage() != null)
|
out.setStatusCode(500);
|
||||||
out.println( "500 Internal Server Error: "+e.getMessage() );
|
if (e.getMessage() != null)
|
||||||
else if(e.getCause() != null){
|
out.println("500 Internal Server Error: " + e.getMessage());
|
||||||
out.println( "500 Internal Server Error: "+e.getCause().getMessage() );
|
else if (e.getCause() != null) {
|
||||||
}
|
out.println("500 Internal Server Error: " + e.getCause().getMessage());
|
||||||
else{
|
} else {
|
||||||
out.println( "500 Internal Server Error: "+e);
|
out.println("500 Internal Server Error: " + e);
|
||||||
|
}
|
||||||
|
}catch(IOException ioe){
|
||||||
|
logger.log(Level.SEVERE, null, ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class HttpFilePage implements HttpPage{
|
||||||
HttpHeaderParser client_info,
|
HttpHeaderParser client_info,
|
||||||
Map<String, Object> session,
|
Map<String, Object> session,
|
||||||
Map<String, String> cookie,
|
Map<String, String> cookie,
|
||||||
Map<String, String> request) {
|
Map<String, String> request) throws IOException{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Is the root only one file or a folder
|
// Is the root only one file or a folder
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class SSDPServer extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
||||||
SSDPServer ssdp = new SSDPServer();
|
SSDPServer ssdp = new SSDPServer();
|
||||||
ssdp.addService(service);
|
ssdp.addService(service);
|
||||||
ssdp.start();
|
ssdp.start();
|
||||||
MultiPrintStream.out.println("SSDP Server running");
|
logger.info("SSDP Server running");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSDPServer() throws IOException{
|
public SSDPServer() throws IOException{
|
||||||
|
|
@ -224,7 +224,7 @@ public class SSDPServer extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,7 +288,7 @@ public class SSDPServer extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
||||||
super.send( packet );
|
super.send( packet );
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -337,7 +337,7 @@ public class SSDPServer extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
||||||
super.send( packet );
|
super.send( packet );
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ package zutil.net.ssdp;
|
||||||
|
|
||||||
import zutil.net.http.HttpPrintStream;
|
import zutil.net.http.HttpPrintStream;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -135,10 +136,14 @@ public class StandardSSDPInfo implements SSDPServiceInfo, SSDPCustomInfo{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeaders(HttpPrintStream http) {
|
public void setHeaders(HttpPrintStream http) {
|
||||||
if(headers != null) {
|
try {
|
||||||
for (String key : headers.keySet()) {
|
if (headers != null) {
|
||||||
http.setHeader(key, headers.get(key));
|
for (String key : headers.keySet()) {
|
||||||
|
http.setHeader(key, headers.get(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}catch(IOException e){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
package zutil.net.upnp;
|
package zutil.net.upnp;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ public class UPnPMediaServer extends UPnPRootDevice{
|
||||||
|
|
||||||
public void respond(HttpPrintStream out, HttpHeaderParser clientInfo,
|
public void respond(HttpPrintStream out, HttpHeaderParser clientInfo,
|
||||||
Map<String, Object> session, Map<String, String> cookie,
|
Map<String, Object> session, Map<String, String> cookie,
|
||||||
Map<String, String> request) {
|
Map<String, String> request) throws IOException {
|
||||||
|
|
||||||
out.enableBuffering(true);
|
out.enableBuffering(true);
|
||||||
out.setHeader("Content-Type", "text/xml");
|
out.setHeader("Content-Type", "text/xml");
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
package zutil.net.upnp.services;
|
package zutil.net.upnp.services;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -154,7 +155,7 @@ public class UPnPContentDirectory implements UPnPService, HttpPage, WSInterface
|
||||||
@WSDisabled
|
@WSDisabled
|
||||||
public void respond(HttpPrintStream out, HttpHeaderParser clientInfo,
|
public void respond(HttpPrintStream out, HttpHeaderParser clientInfo,
|
||||||
Map<String, Object> session, Map<String, String> cookie,
|
Map<String, Object> session, Map<String, String> cookie,
|
||||||
Map<String, String> request) {
|
Map<String, String> request) throws IOException {
|
||||||
|
|
||||||
out.enableBuffering(true);
|
out.enableBuffering(true);
|
||||||
out.setHeader("Content-Type", "text/xml");
|
out.setHeader("Content-Type", "text/xml");
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import zutil.net.http.HttpPage;
|
||||||
import zutil.net.http.HttpPrintStream;
|
import zutil.net.http.HttpPrintStream;
|
||||||
import zutil.net.ws.WebServiceDef;
|
import zutil.net.ws.WebServiceDef;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +45,7 @@ public class WSDLHttpPage implements HttpPage {
|
||||||
HttpHeaderParser client_info,
|
HttpHeaderParser client_info,
|
||||||
Map<String, Object> session,
|
Map<String, Object> session,
|
||||||
Map<String, String> cookie,
|
Map<String, String> cookie,
|
||||||
Map<String, String> request) {
|
Map<String, String> request) throws IOException{
|
||||||
out.setHeader("Content-Type", "text/xml");
|
out.setHeader("Content-Type", "text/xml");
|
||||||
wsdl.write( out );
|
wsdl.write( out );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,7 @@ import zutil.net.ws.WSReturnObject;
|
||||||
import zutil.net.ws.WSReturnObject.WSValueName;
|
import zutil.net.ws.WSReturnObject.WSValueName;
|
||||||
import zutil.net.ws.WebServiceDef;
|
import zutil.net.ws.WebServiceDef;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
@ -62,10 +59,13 @@ public class WSDLWriter{
|
||||||
services.add(serv);
|
services.add(serv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void write( Writer out ) throws IOException {
|
||||||
|
out.write(generate());
|
||||||
|
}
|
||||||
public void write( PrintStream out ) {
|
public void write( PrintStream out ) {
|
||||||
out.print(generate());
|
out.print(generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write( OutputStream out ) throws IOException {
|
public void write( OutputStream out ) throws IOException {
|
||||||
out.write(generate().getBytes() );
|
out.write(generate().getBytes() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class HTTPGuessTheNumber implements HttpPage{
|
||||||
HttpHeaderParser client_info,
|
HttpHeaderParser client_info,
|
||||||
Map<String, Object> session,
|
Map<String, Object> session,
|
||||||
Map<String, String> cookie,
|
Map<String, String> cookie,
|
||||||
Map<String, String> request) {
|
Map<String, String> request) throws IOException {
|
||||||
|
|
||||||
out.enableBuffering(true);
|
out.enableBuffering(true);
|
||||||
out.println("<html>");
|
out.println("<html>");
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,10 @@ public class HTTPUploaderTest implements HttpPage{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void respond(HttpPrintStream out,
|
public void respond(HttpPrintStream out,
|
||||||
HttpHeaderParser client_info,
|
HttpHeaderParser client_info,
|
||||||
Map<String, Object> session,
|
Map<String, Object> session,
|
||||||
Map<String, String> cookie,
|
Map<String, String> cookie,
|
||||||
Map<String, String> request) {
|
Map<String, String> request) throws IOException {
|
||||||
|
|
||||||
if(!session.containsKey("file1")){
|
if(!session.containsKey("file1")){
|
||||||
out.println("</html>" +
|
out.println("</html>" +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue