Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

HTTP PUT
Eridan
#1 Posted : Sunday, December 9, 2007 5:45:52 AM(UTC)
Groups: Member
Joined: 12/7/2007(UTC)
Posts: 7
Location: Belgium

Hi,
I recently installed Cassini to serve a small Intranet app which is based on Http Put requests to save data.
With IIS I can grant Write access to the data file.
With Cassini I get error 405: unauthorized method.
How can I configure write access with Cassini?

Tks for your assistance.
Robert.
Ultidev Team
#2 Posted : Sunday, December 9, 2007 12:38:27 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Robert,

We have not specifically tested HTTP PUT method, so we are not sure whether the problem you are describing is indeed related to write permissions. UltiDev Cassini service runs under pretty powerful LOCAL SYSTEM account, which has write access to most of the non-user folders, so we suspect something may be not right with our support of PUT method. You could do a simple test to check whether this is the case. Run your application in Debugger under UltiDev Cassini web server. If you execution gets to the point where you got your data uploaded to the applications, then it''s permissions issue.

Please let us know what you have found.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Eridan
#3 Posted : Tuesday, December 11, 2007 12:56:38 AM(UTC)
Groups: Member
Joined: 12/7/2007(UTC)
Posts: 7
Location: Belgium

Thank you for your reply.
I confirm that I receive HTTP Error 405 - Method not allowed on submission of the PUT request.
Indeed there is no file system permission issue (everything is tested on localhost), but well a deny of the PUT verb.
The request is defined by HttpWebRequest.Create.

Best regards,
Robert.
Ultidev Team
#4 Posted : Tuesday, December 11, 2007 4:11:48 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hello, Robert.

Would it be possible for you to post a snippet of code you use to create and send PUT request? If you prefer, you can also send the code to us by email.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Eridan
#5 Posted : Tuesday, December 11, 2007 4:33:43 AM(UTC)
Groups: Member
Joined: 12/7/2007(UTC)
Posts: 7
Location: Belgium

Here is the code snippet

Code:
    HttpWebRequest req= (HttpWebRequest) HttpWebRequest.Create (dbPath(dbf));
    req.Method= "PUT"; Stream rs= req.GetRequestStream();
    XmlWriter db= XmlWriter.Create (rs);
    db.WriteNode (new XmlNodeReader(doc), false);
    db.Close(); rs.Close();
    
    HttpWebResponse resp= (HttpWebResponse) req.GetResponse();
    StreamReader st= new StreamReader (resp.GetResponseStream());
    string m= st.ReadToEnd();
    resp.Close(); return m;


I also send the whole dll source via e-mail.

Best regards,
Robert.
Ultidev Team
#6 Posted : Tuesday, December 11, 2007 9:53:21 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hello, Robert.

We were unable to reproduce the problem. Our test ASP.NET 2.0 application running under UltiDev Cassini web server was able to read and return data received over HTTP PUT. Our sever application is essentially a lone HTTP handler. Here's the code of the server application:
Code:
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.IO;

public class Handler : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";

HttpRequest req = context.Request;
if (req.RequestType == "PUT")
{
string data;
using (StreamReader reader = new StreamReader(req.InputStream))
data = reader.ReadToEnd();

context.Response.Write(data);
}
else
context.Response.Write("Hello World");
}

public bool IsReusable {
get {
return false;
}
}
}
We registered server application under UltiDev Cassini for ASP.NET 2.0. We assigned it port 5136.

Our client is a console application with looking like this:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;

namespace HttpPUTtestClient
{
class Program
{
static void Main(string[] args)
{
// Change this \/\/ port value to actual port number
string url = string.Format("http://{0}:5136/Handler.ashx", Environment.MachineName);

int count = 0;
do
{
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.Method = "PUT";

using (Stream rs = req.GetRequestStream())
using (StreamWriter writer = new StreamWriter(rs))
writer.WriteLine(string.Format("Sent data {0}", ++count));

using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
using (StreamReader st = new StreamReader(resp.GetResponseStream()))
{
string m = st.ReadToEnd();
Console.WriteLine(m);
if (Console.ReadKey().Key == ConsoleKey.Escape)
return;
}
} while (true);
}
}
}


When we ran application, here's what we saw on the wire:
Request:
Code:
PUT /Handler.ashx HTTP/1.1
Host: testmachine:5136
Content-Length: 13
Expect: 100-continue
Proxy-Connection: Keep-Alive

Sent data 1

Response:
Code:
HTTP/1.1 200 OK
Server: UltiDev Cassini/2.1.4.3
Date: Tue, 11 Dec 2007 19:44:00 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 13
Connection: Close

Sent data 1


Please let us know if you can replicate our results.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Eridan
#7 Posted : Thursday, December 13, 2007 12:06:43 AM(UTC)
Groups: Member
Joined: 12/7/2007(UTC)
Posts: 7
Location: Belgium

Thank you for the test code.
My scenario consists of a file save operation via Http Put. It does not include Web handler code!
I send by mail a simplified version of my app which implements that only operation.
Could you please try it and see whether you reproduce my problem?
You might prefer to turn it into a console app instead of a Web service GUI.

Best regards,
Robert.
Ultidev Team
#8 Posted : Thursday, December 13, 2007 6:49:19 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Robert,

UltiDev Cassini won't save files when resource is requested by HTTP PUT because UltiDev Cassini does not support application-specific permissions settings. If we were to allow HTTP PUT right now, every application could be spammed with HTTP PUT requests. To receive and save files, an application would have to be written to verify sender's right to do so.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Eridan
#9 Posted : Thursday, December 13, 2007 8:00:50 AM(UTC)
Groups: Member
Joined: 12/7/2007(UTC)
Posts: 7
Location: Belgium

It would be worth mentioning it as a severe discrepancy with IIS and HTTP standards!
Http Put is meaningless with Cassini, because if a server application should handle such requests, Post would be enough.

Regards,
Robert.
Ultidev Team
#10 Posted : Thursday, December 13, 2007 6:37:09 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Robert, we are sorry for the inconvenience, but we are trying to keep our web server simple, and as it is, it covers lots of use cases. HTTP PUT is rarely used because almost always client needs to be authenticated before being allowed to upload. For that, in most cases code has often to be written. As soon as one starts writing code, making your application save files is pretty trivial, so giving up HTTP PUT at web server level is a relatively small price to pay for not having to implement elaborate authentication devices found in IIS.

All the best,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Eridan
#11 Posted : Saturday, December 22, 2007 11:19:13 AM(UTC)
Groups: Member
Joined: 12/7/2007(UTC)
Posts: 7
Location: Belgium

Hello again,

I understand very well the design options that Cassini follows, and I appreciate the commitment to simplicity.
Indeed it was a small effort to add the extra piece handling the file save operation via Post.
It works fine in my Lab environment - BUT I have not been able to make it run in the production (client) system.
I will open a new topic on the forum about this new issue, hoping to keep benefiting from your useful support.

Best regards,
Robert.
Rss Feed  Atom Feed
Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.