There are two bugs in this code:
lookForCode: code ifDifferent: handleBlock
"We are expecting a certain numeric code next.
However, in the FTP protocol, multiple lines are allowed.
If the response is multi-line, the fourth character of the first line is a
$- and the last line repeats the numeric code but the code is followed by
a space. So it's possible that there are more lines left of the last
response that
we need to throw away. We use peekForAll: so that we don't discard the
next response that is not a continuation line."
| headToDiscard |
"check for multi-line response"
(self lastResponse size > 3
and: [(self lastResponse at: 4) = $-])
ifTrue: ["Discard continuation lines."
[headToDiscard _ self lastResponse first: 4.
[[self stream peekForAll: headToDiscard]
whileTrue: [self stream nextLine]]
on: Exception
do: [:ex | ^handleBlock value: nil]]].
^ super lookForCode: code ifDifferent: handleBlock
1) it attempts to catch Exception, which is generally a bad idea.
Error would be more appropriated.
2) but the whole ifTrue: conditions is a no-op: it simply creates a
block that is not used.
Maybe intention was:
ifTrue: ["Discard continuation lines."
headToDiscard := self lastResponse first: 4.
[[self stream peekForAll: headToDiscard]
whileTrue: [self stream nextLine]]
on: Exception
do: [:ex | ^handleBlock value: nil]].
Is this code used?
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project