From b8be18672056b7e2aeec08f3ec1e29a276a44c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 28 Jul 2014 20:26:47 +0200 Subject: [PATCH] gopher: Handle errors from Gophernicus It sends them as plain text instead of gopher directory when it doesn't find something... --- src/kits/network/libnetapi/GopherRequest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/kits/network/libnetapi/GopherRequest.cpp b/src/kits/network/libnetapi/GopherRequest.cpp index 13193de85b..9f5c3b3ed5 100644 --- a/src/kits/network/libnetapi/GopherRequest.cpp +++ b/src/kits/network/libnetapi/GopherRequest.cpp @@ -316,6 +316,16 @@ BGopherRequest::_ProtocolLoop() // continue parsing the error text anyway } } + // special case for buggy(?) Gophernicus/1.5 + static const char *buggy = "Error: File or directory not found!"; + if (fInputBuffer.Size() > strlen(buggy) + && !memcmp(fInputBuffer.Data(), buggy, strlen(buggy))) { + fItemType = GOPHER_TYPE_DIRECTORY; + readError = B_RESOURCE_NOT_FOUND; + // continue parsing the error text anyway + // but it won't look good + } + // now we probably have correct data dataValidated = true;