Patch for trailing null (DG814)
Brought to you by:
skonno
Netgear DG814 router returns a trailing null after the
soap response. Patch for
org.cybergarage.soap.SOAPRequest to fix (only relevant
lines shown):
public SOAPResponse postMessage(String host, int port)
{
HTTPResponse httpRes = post(host, port);
SOAPResponse soapRes = new SOAPResponse(httpRes);
byte content[] = soapRes.getContent();
int len = content.length;
if (len <= 0)
return soapRes;
// trim trailing null (DG814)
if(content[len-1] == '\0')
len--;
try {
ByteArrayInputStream byteIn = new
ByteArrayInputStream(content, 0, len);
Logged In: YES
user_id=901512
Originator: NO
Is your patch general purpose? At first glace, it seems to me that will break the behavior with device non sending a extra 'null' character
Logged In: YES
user_id=133877
Originator: YES
Yes, it is general purpose. It checks if the last character is null. If it is null (as in the case of DG814) then it removes the null. If the response doesnt send an extra null, then it's not removed.