IDLnetURL and SOCKET [message #89506] |
Wed, 22 October 2014 12:51  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Is there a way to open a file unit on a http:// server so that it can be processed with IDL? One can do this with the SOCKET procedure, and I have a program that will open a file on a remote server with SOCKET, which can then be processed with IDL commands (e.g. READU).
http://idlastro.gsfc.nasa.gov/ftp/pro/sockets/webget.pro
The problem is that SOCKET provides no framework for communicating with an http: server (e.g taking care of things like proxy servers, passwords, SSL certificates etc. ) and so I need to write these myself. The IDLNetURL object does take care of most of the http communication protocols and I have happily used it to copy remote files to disk or to a buffer. But I don't believe it is possible to open a remote file with IDLNetURL -- for example, if one just wants to read the first line of a remote file and not read the entire file. So what I think I need is some way to combine SOCKET and IDLnetURL.
Or perhaps I need think about this in a different way. Thanks, --Wayne
|
|
|
Re: IDLnetURL and SOCKET [message #89528 is a reply to message #89506] |
Thu, 23 October 2014 09:04   |
Dominic[2]
Messages: 3 Registered: October 2014
|
Junior Member |
|
|
On Wednesday, October 22, 2014 3:51:13 PM UTC-4, wlandsman wrote:
> Is there a way to open a file unit on a http:// server so that it can be processed with IDL? One can do this with the SOCKET procedure, and I have a program that will open a file on a remote server with SOCKET, which can then be processed with IDL commands (e.g. READU).
>
> http://idlastro.gsfc.nasa.gov/ftp/pro/sockets/webget.pro
>
> The problem is that SOCKET provides no framework for communicating with an http: server (e.g taking care of things like proxy servers, passwords, SSL certificates etc. ) and so I need to write these myself. The IDLNetURL object does take care of most of the http communication protocols and I have happily used it to copy remote files to disk or to a buffer. But I don't believe it is possible to open a remote file with IDLNetURL -- for example, if one just wants to read the first line of a remote file and not read the entire file. So what I think I need is some way to combine SOCKET and IDLnetURL.
>
> Or perhaps I need think about this in a different way. Thanks, --Wayne
Hi Wayne,
Try this:
http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/sockets/web read.pro
If the server supports byte-serving, you can selectively read a range of bytes as follows:
IDL> f= http://sohowww.nascom.nasa.gov/pickoftheweek/Oct_C3_halo.jpg
;-- read whole file
IDL> o=webread(f,response=response)
IDL> print,response
HTTP/1.1 200 OK
Date: Thu, 23 Oct 2014 15:56:15 GMT
Server: Apache/2.4.10 (Unix)
Last-Modified: Fri, 17 Oct 2014 20:05:21 GMT
ETag: "24b46-505a3e28764e6"
Accept-Ranges: bytes
Content-Length: 150342
Content-Type: image/jpeg
;-- read 101 bytes
IDL> o=webread(f,response=response,range=[100,200])
Range: bytes=100-200
IDL> print,response
HTTP/1.1 206 Partial Content
Date: Thu, 23 Oct 2014 15:56:31 GMT
Server: Apache/2.4.10 (Unix)
Last-Modified: Fri, 17 Oct 2014 20:05:21 GMT
ETag: "24b46-505a3e28764e6"
Accept-Ranges: bytes
Content-Length: 101
Content-Range: bytes 100-200/150342
Content-Type: image/jpeg
Dominic
|
|
|
|