Mercurial Hosting > luan
changeset 1759:6668513a11d7
fix PUT
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 10 Apr 2023 17:43:47 -0600 |
parents | 0e59609c3173 |
children | 13da09b5b13b |
files | src/luan/modules/url/LuanUrl.java |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
diff -r 0e59609c3173 -r 6668513a11d7 src/luan/modules/url/LuanUrl.java --- a/src/luan/modules/url/LuanUrl.java Mon Feb 06 19:33:45 2023 -0700 +++ b/src/luan/modules/url/LuanUrl.java Mon Apr 10 17:43:47 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 ) {