|
2022-05-11
| ||
| 03:06 | • Closed ticket [9172a66e40]: HTTP 1.1 chunk support incompatible with -channel op... artifact: 03b51f7c81 user: kjnash | |
|
2015-09-06
| ||
| 13:07 | • Ticket [9172a66e40]: 3 changes artifact: 38a39577d9 user: dkf | |
|
2015-08-26
| ||
| 18:38 | • Ticket [9172a66e40]: 4 changes artifact: ec60adf70f user: dgp | |
|
2015-08-18
| ||
| 15:20 | • Ticket [9172a66e40]: 3 changes artifact: b721650e2e user: ferrieux | |
| 14:58 | • Ticket [9172a66e40]: 4 changes artifact: 1263932b54 user: oehhar | |
| 14:48 | • New ticket [9172a66e40]. artifact: be70200b82 user: pchai26 | |
HTTP 1.1 chunk support incompatible with -channel option
Closed / Fixed9172a66e4078f9a70d9ad439f38d99a2ca2cddb0Created 11 years agoUpdated 5 years ago
Descriptionplain2015-08-18 14:48:31
Hello Tcl Core Team, I am having an issue with http 2.7+, with Tcl 8.5+. First, if you put this url string in browser (Chrome, firefox, IE, etc,): “http://skyview.gsfc.nasa.gov/cgi-bin/pskcall?VCOORD=ETA%20Carinae&SURVEY=DSS&SCOORD=Equatorial&SFACTR=Default&PIXELX=300&PIXELY=300” It will produce a data file (astronomical data file.) The data file is correct and being our test benchmark. But if you tried these commands under TCLSH: package require http set skyviewout [open “test.fits” w] set token [::http:: geturl “http://skyview.gsfc.nasa.gov/cgi-bin/pskcall” -channel $skyviewout -query “VCOORD=ETA%20Carinae&SURVEY=DSS&SCOORD=Equatorial&SFACTR=Default&PIXELX=300&PIXELY=300”] close $skyviewout It then produces a corrupted data file that has some undeciphiable strings at beginning of the data file, a line consists of “400^M" and maybe somewhere else in the data file (like break line with “5000^M”) too. These TCLSH commands used to work fine. Just as soon as we upgrade to http package 2.7+, it suddenly produced strange results, and it is making reading those astronomical data files impossible. Can you help?
oehharplain2015-08-18 14:58:03
Peter S commented: I tested your command with http 2.7.13, and I experience the same. However, if I use [set data [http::data $token]] and save it to a file instead of using the -channel parameter, then the data seems correct. So that may be a (temporary) workaround.
ferrieuxplain2015-08-18 15:20:51
The issue is that when upgrading, the Tcl HTTP client selected
protocol version 1.1, which allowed the server to use chunked encoding
transfer. Those 400^M and 5000^M are chunk length prefixes.
Unfortunately, the chunk support in the HTTP package does not extend
to "-channel" mode; in this case the channel receives the
chunked-encoded flow unmodified.
As a workaround, avoid the -channel option; sure, the body will flow
into RAM instead, but will be correctly 'de-chunked':
% set token [::http::geturl
{http://skyview.gsfc.nasa.gov/cgi-bin/pskcall?VCOORD=ETA%20Carinae&SURVEY=DSS&SCOORD=Equatorial&SFACTR=Default&PIXELX=300&PIXELY=300}]
::http::1
% set x [http::data ::http::1];set y [string length $x]
374400
% string range $x 0 20
SIMPLE =
%
(note also above that I didn't use -query, meaning a POST, since your
primary example in a browser is a GET)
Also note that when saving to a binary file you might want to
[fconfigure -translation binary] to avoid unwanted translations.
Wrapping it up:
package require http
set token [::http::geturl
{http://skyview.gsfc.nasa.gov/cgi-bin/pskcall?VCOORD=ETA%20Carinae&SURVEY=DSS&SCOORD=Equatorial&SFACTR=Default&PIXELX=300&PIXELY=300}]
set skyviewout [open “test.fits” w]
fconfigure $skyviewout -translation binary
puts -nonewline $skyviewout [http::data $token]
dgp Ticket [9172a66e40]: 4 changes
[History diff]2015-08-26 18:38:49
dkf Ticket [9172a66e40]: 3 changes
[History diff]2015-09-06 13:07:54
kjnashplain2022-05-11 03:06:09
The response from this URL is now a redirect to the corresponding https URL: https://skyview.gsfc.nasa.gov/cgi-bin/pskcall?VCOORD=ETA%20Carinae&SURVEY=DSS&SCOORD=Equatorial&SFACTR=Default&PIXELX=300&PIXELY=300 Using the second URL, the transfer is indeed chunked: the response headers include "Transfer-Encoding chunked". The file is now the same when downloaded by http::geturl 2.10a1 as when downloaded by a web browser, with the exception of two datestamps and an internal filename. This bug with chunked encoding was fixed years ago. I have closed the ticket.
Log in (anonymous is fine) to add a comment.