Fetching a file from a web site with a URL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Fetching a file from a web site with a URL

Louis LaBrunda
Hi All,

I would like to use:

SstHttpClient fetch: 'https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:


in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Fetching a file from a web site with a URL

Seth Berman
Hi Lou,

What version of the product?
What version of OpenSSL libraries are you using?

- Seth

On Wednesday, July 12, 2017 at 3:20:18 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to use:

SstHttpClient fetch: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:

SstHttpClient fetch: '<a href="http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;">http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt'.

in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Fetching a file from a web site with a URL

Seth Berman
Try
'https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch
instead.

Or
| client result |
client := SstHttpClient forTransportScheme: 'httpsl'.
client startUp.
[result := (client get: 'https://treasurydirect.gov/xml/CPI_20170614.xml') basicContents asString]
    ensure: [client shutDown]

would also work

On Wednesday, July 12, 2017 at 3:56:53 PM UTC-4, Seth Berman wrote:
Hi Lou,

What version of the product?
What version of OpenSSL libraries are you using?

- Seth

On Wednesday, July 12, 2017 at 3:20:18 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to use:

SstHttpClient fetch: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:

SstHttpClient fetch: '<a href="http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;">http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt'.

in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Fetching a file from a web site with a URL

Louis LaBrunda
Hi Seth,

Thanks.


Is there any reason to use your second suggestion?  Like cleaning up after an error?

Lou



On Wednesday, July 12, 2017 at 4:12:59 PM UTC-4, Seth Berman wrote:
Try
'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch
instead.

Or
| client result |
client := SstHttpClient forTransportScheme: 'httpsl'.
client startUp.
[result := (client get: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml') basicContents asString]
    ensure: [client shutDown]

would also work

On Wednesday, July 12, 2017 at 3:56:53 PM UTC-4, Seth Berman wrote:
Hi Lou,

What version of the product?
What version of OpenSSL libraries are you using?

- Seth

On Wednesday, July 12, 2017 at 3:20:18 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to use:

SstHttpClient fetch: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:

SstHttpClient fetch: '<a href="http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;">http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt'.

in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Fetching a file from a web site with a URL

Seth Berman
Hi Lou,

My second suggestion is pretty much what SstHttpUrl>>fetch does.
I really just wanted to show the modified version of what you were trying to use.

SstHttpUrl>>fetch actually does error checking on the fetch and content string retrieval.
My SstHttpClient example doesn't.

SstHttpClient is nicer if you plan to reuse it for more than 1 call (and perhaps customize) since
you are not forced to do startUp/shutDowns between every call you would make (which is what SstHttpUrl>>fetch does).

-- Seth

On Wednesday, July 12, 2017 at 5:54:08 PM UTC-4, Louis LaBrunda wrote:
Hi Seth,

Thanks.

'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" style="font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch

works great.

Is there any reason to use your second suggestion?  Like cleaning up after an error?

Lou



On Wednesday, July 12, 2017 at 4:12:59 PM UTC-4, Seth Berman wrote:
Try
'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch
instead.

Or
| client result |
client := SstHttpClient forTransportScheme: 'httpsl'.
client startUp.
[result := (client get: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml') basicContents asString]
    ensure: [client shutDown]

would also work

On Wednesday, July 12, 2017 at 3:56:53 PM UTC-4, Seth Berman wrote:
Hi Lou,

What version of the product?
What version of OpenSSL libraries are you using?

- Seth

On Wednesday, July 12, 2017 at 3:20:18 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to use:

SstHttpClient fetch: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:

SstHttpClient fetch: '<a href="http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;">http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt'.

in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Fetching a file from a web site with a URL

Louis LaBrunda
Hi Seth,

Thanks.  Tomorrow I will play with the second version to handle the case when the file isn't present.  The government creates the file once a month around the middle of the month.  I have to guess at the date/name to get the latest version for the file.  That's shouldn't be a problem, I just need to play with what comes back and get the string when it is good.

I will post what I end up with when done.

Lou

On Wednesday, July 12, 2017 at 6:04:12 PM UTC-4, Seth Berman wrote:
Hi Lou,

My second suggestion is pretty much what SstHttpUrl>>fetch does.
I really just wanted to show the modified version of what you were trying to use.

SstHttpUrl>>fetch actually does error checking on the fetch and content string retrieval.
My SstHttpClient example doesn't.

SstHttpClient is nicer if you plan to reuse it for more than 1 call (and perhaps customize) since
you are not forced to do startUp/shutDowns between every call you would make (which is what SstHttpUrl>>fetch does).

-- Seth

On Wednesday, July 12, 2017 at 5:54:08 PM UTC-4, Louis LaBrunda wrote:
Hi Seth,

Thanks.

'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" style="font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch

works great.

Is there any reason to use your second suggestion?  Like cleaning up after an error?

Lou



On Wednesday, July 12, 2017 at 4:12:59 PM UTC-4, Seth Berman wrote:
Try
'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch
instead.

Or
| client result |
client := SstHttpClient forTransportScheme: 'httpsl'.
client startUp.
[result := (client get: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml') basicContents asString]
    ensure: [client shutDown]

would also work

On Wednesday, July 12, 2017 at 3:56:53 PM UTC-4, Seth Berman wrote:
Hi Lou,

What version of the product?
What version of OpenSSL libraries are you using?

- Seth

On Wednesday, July 12, 2017 at 3:20:18 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to use:

SstHttpClient fetch: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:

SstHttpClient fetch: '<a href="http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;">http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt'.

in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Fetching a file from a web site with a URL

Louis LaBrunda
Hi Seth,

For testing I rearranged your example as such:


| client result url filename fileStream |
filename := 'CPI_20170614.xml'.
url := 'https://treasurydirect.gov/xml/', filename.
client := SstHttpClient forTransportScheme: 'httpsl'.
client startUp.
[result := client get: url] ensure: [client shutDown].
result isSstError ifFalse: [
filestream := CfsWriteFileStream openEmpty: 'D:\Temp\', filename.
filestream nextPutAll: result basicContents.
filestream close.
].


on error, say the URL points to a non existent file, the error is ignored.  If the file is present, I save it to disk.  I won't actually do that later but for testing it is great.

Thanks again.

Lou



On Wednesday, July 12, 2017 at 7:45:59 PM UTC-4, Louis LaBrunda wrote:
Hi Seth,

Thanks.  Tomorrow I will play with the second version to handle the case when the file isn't present.  The government creates the file once a month around the middle of the month.  I have to guess at the date/name to get the latest version for the file.  That's shouldn't be a problem, I just need to play with what comes back and get the string when it is good.

I will post what I end up with when done.

Lou

On Wednesday, July 12, 2017 at 6:04:12 PM UTC-4, Seth Berman wrote:
Hi Lou,

My second suggestion is pretty much what SstHttpUrl>>fetch does.
I really just wanted to show the modified version of what you were trying to use.

SstHttpUrl>>fetch actually does error checking on the fetch and content string retrieval.
My SstHttpClient example doesn't.

SstHttpClient is nicer if you plan to reuse it for more than 1 call (and perhaps customize) since
you are not forced to do startUp/shutDowns between every call you would make (which is what SstHttpUrl>>fetch does).

-- Seth

On Wednesday, July 12, 2017 at 5:54:08 PM UTC-4, Louis LaBrunda wrote:
Hi Seth,

Thanks.

'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" style="font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch

works great.

Is there any reason to use your second suggestion?  Like cleaning up after an error?

Lou



On Wednesday, July 12, 2017 at 4:12:59 PM UTC-4, Seth Berman wrote:
Try
'<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml' sstAsUrl fetch
instead.

Or
| client result |
client := SstHttpClient forTransportScheme: 'httpsl'.
client startUp.
[result := (client get: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml') basicContents asString]
    ensure: [client shutDown]

would also work

On Wednesday, July 12, 2017 at 3:56:53 PM UTC-4, Seth Berman wrote:
Hi Lou,

What version of the product?
What version of OpenSSL libraries are you using?

- Seth

On Wednesday, July 12, 2017 at 3:20:18 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to use:

SstHttpClient fetch: '<a href="https://treasurydirect.gov/xml/CPI_20170614.xml" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ftreasurydirect.gov%2Fxml%2FCPI_20170614.xml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGJE4KXVzc6Bxt7Y38Q67mMXTHTVQ&#39;;return true;">https://treasurydirect.gov/xml/CPI_20170614.xml'.

or something like it to download the file into a Smalltalk program as a big string.  I have used:

SstHttpClient fetch: '<a href="http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.keystone-software.com%2Fftp%2Fdownload%2Fwindows%2FX10%2FVersion.Txt\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvjeYgtA0HIJR2SnVkTRLjyON8MQ&#39;;return true;">http://www.keystone-software.com/ftp/download/windows/X10/Version.Txt'.

in the past and it works great.  I think the problem has something to do with the 'https:' which is different than the 'http:'.

Any ideas?

It does seem to get a response but no data.  I have also tried #fetchForPeerIdViolation: but it seems to hang loading a DLL.

Thanks in advance.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.