changeset 1760:13da09b5b13b

merge
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Apr 2023 17:46:41 -0600
parents 6668513a11d7 (diff) 27a2530f04b6 (current diff)
children e41282c4528c
files
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
diff -r 27a2530f04b6 -r 13da09b5b13b src/luan/modules/url/LuanUrl.java
--- a/src/luan/modules/url/LuanUrl.java	Mon Feb 20 09:02:20 2023 +0200
+++ b/src/luan/modules/url/LuanUrl.java	Mon Apr 10 17:46:41 2023 -0600
@@ -100,8 +100,8 @@
 			String enctype = Utils.removeString(options,"enctype");
 			Object content = options.remove("content");
 			if( content != null ) {
-				if( this.method != Method.POST )
-					throw new LuanException( "content can only be used with POST" );
+				if( this.method != Method.POST && this.method != Method.PUT )
+					throw new LuanException( "content can only be used with POST or PUT" );
 				if( params != null )
 					throw new LuanException( "content cannot be used with parameters" );
 				if( content instanceof String ) {
@@ -114,8 +114,8 @@
 			if( enctype != null ) {
 				if( !enctype.equals("multipart/form-data") )
 					throw new LuanException( "unrecognized enctype: "+enctype );
-				if( this.method != Method.POST )
-					throw new LuanException( "multipart/form-data can only be used with POST" );
+				if( this.method != Method.POST && this.method != Method.PUT )
+					throw new LuanException( "multipart/form-data can only be used with POST or PUT" );
 				if( params==null )
 					throw new LuanException( "multipart/form-data requires parameters" );
 				if( params.isEmpty() )
@@ -247,16 +247,18 @@
 			return getInputStream(httpCon,authorization);
 		}
 
+/*
 		if( method==Method.PUT ) {
 			httpCon.setRequestMethod("PUT");
 			return getInputStream(httpCon,authorization);
 		}
+*/
 
-		// POST
+		// POST or PUT
 
 //		httpCon.setRequestProperty("content-type","application/x-www-form-urlencoded");
 		httpCon.setDoOutput(true);
-		httpCon.setRequestMethod("POST");
+		httpCon.setRequestMethod(method.toString());
 
 		OutputStream out;
 		if( multipart != null ) {