Connecting Tech Pros Worldwide Forums | Help | Site Map

using PUT with XMLHTTP

Kamen TOMOV
Guest
 
Posts: n/a
#1: Jan 23 '06
Hi,

Do you know if it is possible to use the PUT method with the XMLHTTP
object and if yes what the client side code should look like?

I would like to PUT a file on the server. I got stuck here:

var ajax = new_ajax_obj();
ajax.open ('PUT', file, true);
ajax.send ('');

I failed to find a good documentation of the "send" method so that I
can specify a particular file.

Any help will be appreciated.

--
Kamen TOMOV

jgwyman@gmail.com
Guest
 
Posts: n/a
#2: Jan 24 '06

re: using PUT with XMLHTTP


To the best of my knowledge you cannot use PUT with the XmlHTTP object.
:-(

Sorry.

If you find out how, I'd love to know.

I've been using an iFrame for a similar effect.

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#3: Jan 24 '06

re: using PUT with XMLHTTP


Kamen TOMOV wrote:
[color=blue]
> Do you know if it is possible to use the PUT method with the XMLHTTP
> object[/color]

The IXMLHTTPRequest interface reference[1] says it is possible, the XUL
Object Reference[2] says it is not. I have never tried anything else
than GET or POST to date.
[color=blue]
> and if yes what the client side code should look like?
> I would like to PUT a file on the server. I got stuck here:
>
> var ajax = new_ajax_obj();
> ajax.open ('PUT', file, true);
> ajax.send ('');
>
> I failed to find a good documentation of the "send" method so that I
> can specify a particular file.[/color]

You cannot specify a particular file there. If you want to use PUT, you
need a HTTP server and a resource that supports it (indicated by an
"Allow: ...,PUT" response header) and send it the _content_ of the file
you want to replace the resource with as the request body [as argument of
send()]. See RFC1945 (HTTP/1.0), appendix D, subsection 1.1.[3], and
RFC2616 (HTTP/1.1), subsection 9.6.[4] You will need additional host
objects for file access to retrieve that file content.[5]


HTH

PointedEars
___________
[1]
<URL:http://msdn.microsoft.com/library/en-us/xmlsdk/html/7924f6be-c035-411f-acd2-79de7a711b38.asp>
[2]
<URL:http://xulplanet.com/references/objref/XMLHttpRequest.html#method_open>
[3] <URL:http://www.rfc-editor.org/rfc/rfc1945.txt>
[4] <URL:http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html>
[5] <URL:http://xulplanet.com/references/xpcomref/group_Files.html>
<URL:http://msdn.microsoft.com/library/en-us/script56/html/jsobjfilesystem.asp>
Kamen TOMOV
Guest
 
Posts: n/a
#4: Jan 24 '06

re: using PUT with XMLHTTP


On Tue, Jan 24 2006, Thomas 'PointedEars' Lahn wrote:
[color=blue]
> You will need additional host objects for file access to retrieve
> that file content.[5]
> ..[/color]

And is there a generic JavaScript functionality that could be used for
reading a file beside using XUL?

Thank you.

--
Kamen TOMOV
VK
Guest
 
Posts: n/a
#5: Jan 24 '06

re: using PUT with XMLHTTP



Kamen TOMOV wrote:[color=blue]
> And is there a generic JavaScript functionality that could be used for
> reading a file beside using XUL?
>
> Thank you.[/color]

XPConnect (Gecko) / FileSystemObject (IE)

But FileSystemObject allows you to read only text files (TXT, XML,
HTTP). For binary files you're getting only file header. So no, there
is nothing universal / generic: except <input type="file"> and file
upload over HTTP in base64. This is fully universal and I'm affraid
this is what you'll have to live with for now. At least until any other
browser besides Amaya will support PUT method (I wouldn't count on it
too much).

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#6: Jan 24 '06

re: using PUT with XMLHTTP


Kamen TOMOV wrote:
[color=blue]
> On Tue, Jan 24 2006, Thomas 'PointedEars' Lahn wrote:[color=green]
>> You will need additional host objects for file access to retrieve
>> that file content.[5]
>> ..[/color]
>
> And is there a generic JavaScript functionality that could be used for
> reading a file beside using XUL?[/color]

As I said you have to use host objects for filesystem access (because
neither language discussed here provides for that feature natively). It is
possible to implement a generic interface with JS/ECMAScript to provide for
transparent file system access through it if either host object is
supported, but of course JavaScript does not provide for such an interface
natively.

It should be added that XMLHTTPRequest itself (which refers to another host
object) can provide for _read_ access to file content even if the local
system is not running a Web server, so you do not need the FileSystemObject
object or XUL filesystem objects for that necessarily; however, the Same
Origin Policy and other security restrictions apply in that case, too.

Please use _all_ the URLs I have provided and get informed first. Come back
again (and continue _this_ thread) if you have specific problems in making
your approach work.

<URL:http://jibbering.com/faq/>


PointedEars
Jasen Betts
Guest
 
Posts: n/a
#7: Jan 25 '06

re: using PUT with XMLHTTP


On 2006-01-23, Kamen TOMOV <kamen@evrocom.net> wrote:[color=blue]
> Hi,
>
> Do you know if it is possible to use the PUT method with the XMLHTTP
> object and if yes what the client side code should look like?
>
> I would like to PUT a file on the server. I got stuck here:
>
> var ajax = new_ajax_obj();
> ajax.open ('PUT', file, true);
> ajax.send ('');
>
> I failed to find a good documentation of the "send" method so that I
> can specify a particular file.
>
> Any help will be appreciated.[/color]

PUT is not well supported (by servers), file uploads are usually done
using POST with multipart content and CGI support on ther server.
--

Bye.
Jasen
VK
Guest
 
Posts: n/a
#8: Jan 25 '06

re: using PUT with XMLHTTP



Jasen Betts wrote:[color=blue]
> PUT is not well supported (by servers), file uploads are usually done
> using POST with multipart content and CGI support on ther server.[/color]

PUT is not supported *by current browsers* (except Amaya, but this W3C
ugly baby is not usable for browsing).

On the server side you can instruct server to accept even FOOBAR
requests if you want to, so again - it's the limitation from the client
side.

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#9: Jan 25 '06

re: using PUT with XMLHTTP


VK wrote:
[color=blue]
> Jasen Betts wrote:[color=green]
>> PUT is not well supported (by servers), file uploads are usually done
>> using POST with multipart content and CGI support on ther server.[/color]
>
> PUT is not supported *by current browsers*[/color]

Nonsense.
[color=blue]
> (except Amaya, but this W3C ugly baby is not usable for browsing).[/color]

Fortunately, you do not set the standards for the Web.
[color=blue]
> On the server side you can instruct server to accept even FOOBAR
> requests[/color]

That would not be a _HTTP_ server anymore.
[color=blue]
> if you want to, so again - it's the limitation from the client side.[/color]

No, it is not. Learn to understand the difference between (HTTP) clients
and browsers.


PointedEars
VK
Guest
 
Posts: n/a
#10: Jan 25 '06

re: using PUT with XMLHTTP



Thomas 'PointedEars' Lahn wrote:[color=blue]
> VK wrote:
>[color=green]
> > Jasen Betts wrote:[color=darkred]
> >> PUT is not well supported (by servers), file uploads are usually done
> >> using POST with multipart content and CGI support on ther server.[/color]
> >
> > PUT is not supported *by current browsers*[/color]
>
> Nonsense.[/color]

Then please post here a *working* sample of PUT request using Firefox,
IE, Opera, Netscape, Camino, Safari (*any* of these, you don't need to
cover all of them).

A hint: you can do it with NCSA Mosaic, Netscape Composer (4.x package)
and W3C Amaya. What is the difference? That's your homework.

P.S. By "working sample" I did not mean a whole separate application
with an open interface accessed over JavaScript/JScript from a browser
page. This way JavaScript is capable for everything in the world: known
and unknown :-)

Randy Webb
Guest
 
Posts: n/a
#11: Jan 25 '06

re: using PUT with XMLHTTP


VK said the following on 1/25/2006 2:36 PM:[color=blue]
> Thomas 'PointedEars' Lahn wrote:[color=green]
>> VK wrote:
>>[color=darkred]
>>> Jasen Betts wrote:
>>>> PUT is not well supported (by servers), file uploads are usually done
>>>> using POST with multipart content and CGI support on ther server.
>>> PUT is not supported *by current browsers*[/color]
>> Nonsense.[/color]
>
> Then please post here a *working* sample of PUT request using Firefox,
> IE, Opera, Netscape, Camino, Safari (*any* of these, you don't need to
> cover all of them).[/color]

Ummm, you missed the very important omission of saying it is not
supported by JScript, Javascript, or the venerable ECMAScript because
browsers *do* support PUT, just not through scripting.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
VK
Guest
 
Posts: n/a
#12: Jan 25 '06

re: using PUT with XMLHTTP



Randy Webb wrote:[color=blue]
> Ummm, you missed the very important omission of saying it is not
> supported by JScript, Javascript, or the venerable ECMAScript because
> browsers *do* support PUT[/color]

I *hate* to be pedantic but who missed to say that?
:-)

Randy Webb
Guest
 
Posts: n/a
#13: Jan 25 '06

re: using PUT with XMLHTTP


VK said the following on 1/25/2006 3:11 PM:[color=blue]
> Randy Webb wrote:[color=green]
>> Ummm, you missed the very important omission of saying it is not
>> supported by JScript, Javascript, or the venerable ECMAScript because
>> browsers *do* support PUT[/color]
>
> I *hate* to be pedantic but who missed to say that?
> :-)
>[/color]

I would tell you but then he would give me another vote for President of
the People called Troll by Thomas Lahn Club.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
VK
Guest
 
Posts: n/a
#14: Jan 25 '06

re: using PUT with XMLHTTP


<offtopic>

VK wrote:[color=blue]
> At least until any other browser besides
> Amaya will support PUT method (I wouldn't count on
> it too much).[/color]

Randy Webb wrote:[color=blue][color=green]
>> Ummm, you missed the very important omission of saying it is not
>> supported by JScript, Javascript, or the venerable ECMAScript because
>> browsers *do* support PUT[/color][/color]

VK wrote:[color=blue][color=green][color=darkred]
>>> I *hate* to be pedantic but who missed to say that?
>>> :-)[/color][/color][/color]

Randy Webb wrote:[color=blue][color=green][color=darkred]
>>>> I would tell you but then he would give me another vote for President of
>>>> the People called Troll by Thomas Lahn Club.[/color][/color][/color]

I'm sorry, I'm far away from running for doubtious credits for saying
something non-vitally important an instance before someone said
something equally non-important :-)

Just let you know that your last sentence ("I would tell...") allows 3
equally possible readings (over semantical analyzation) where A is
right, B is right, and both A and B are wrong. That's kind of sentence
one pays long bucks for in politics.

Just FYI

:-)

</offtopic>

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#15: Jan 25 '06

re: using PUT with XMLHTTP


VK wrote:
[color=blue]
> Thomas 'PointedEars' Lahn wrote:[color=green]
>> VK wrote:[color=darkred]
>> > Jasen Betts wrote:
>> >> PUT is not well supported (by servers), file uploads are usually done
>> >> using POST with multipart content and CGI support on ther server.
>> >
>> > PUT is not supported *by current browsers*[/color]
>> Nonsense.[/color]
>
> [...] you can do it with [...] W3C Amaya. What is the difference? That's
> your homework.[/color]

If you would have done your homework, I would not have to point out that
e.g. the latest Amaya versions (9.3/8.8.3) were released December 9, 2005.
In case you have problems with your calendar: That was 9 days _after_ the
latest Firefox release. The support for HTTP PUT was introduced in Amaya
version 7.2 (February 3, 2003), BTW.

<URL:http://www.w3.org/Amaya/User/New.html>


PointedEars
Randy Webb
Guest
 
Posts: n/a
#16: Jan 26 '06

re: using PUT with XMLHTTP


VK said the following on 1/25/2006 5:10 PM:[color=blue]
> <offtopic>
>
> VK wrote:[color=green]
>> At least until any other browser besides
>> Amaya will support PUT method (I wouldn't count on
>> it too much).[/color]
>
> Randy Webb wrote:[color=green][color=darkred]
>>> Ummm, you missed the very important omission of saying it is not
>>> supported by JScript, Javascript, or the venerable ECMAScript because
>>> browsers *do* support PUT[/color][/color]
>
> VK wrote:[color=green][color=darkred]
>>>> I *hate* to be pedantic but who missed to say that?
>>>> :-)[/color][/color]
>
> Randy Webb wrote:[color=green][color=darkred]
>>>>> I would tell you but then he would give me another vote for President of
>>>>> the People called Troll by Thomas Lahn Club.[/color][/color]
>
> I'm sorry, I'm far away from running for doubtious credits for saying
> something non-vitally important an instance before someone said
> something equally non-important :-)[/color]

I stopped worrying about TL calling me a troll long ago. It happens so
often that it has lost it's meaning.
[color=blue]
> Just let you know that your last sentence ("I would tell...") allows 3
> equally possible readings (over semantical analyzation) where A is
> right, B is right, and both A and B are wrong. That's kind of sentence
> one pays long bucks for in politics.
>
> Just FYI[/color]

Maybe I should consider becoming a political writer. Hmmmmmm

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Closed Thread