Skip to content

Commit

Permalink
Alert that file:// only supports local files
Browse files Browse the repository at this point in the history
git-svn-id: https://anonsvn.ncbi.nlm.nih.gov/repos/v1/trunk/c++@102624 78c7ea69-d796-4a43-9a09-de51944f1b03
  • Loading branch information
alavrentiev committed Jun 13, 2024
1 parent 8838ac5 commit 7c909f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/connect/error_codes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ BEGIN_NCBI_SCOPE

// Here are only error codes used in C++ sources.
// For error codes used in C sources see src/connect/ncbi_priv.h.
NCBI_DEFINE_ERRCODE_X(Connect_Stream, 315, 17);
NCBI_DEFINE_ERRCODE_X(Connect_Stream, 315, 18);
NCBI_DEFINE_ERRCODE_X(Connect_Pipe, 316, 15);
NCBI_DEFINE_ERRCODE_X(Connect_ThrServer, 317, 11);
NCBI_DEFINE_ERRCODE_X(Connect_Core, 318, 11);
Expand Down
11 changes: 8 additions & 3 deletions src/connect/ncbi_conn_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@
#include "ncbi_priv.h"
#include "ncbi_servicep.h"
#include "ncbi_socketp.h"
#include <connect/error_codes.hpp>
#include <connect/ncbi_conn_exception.hpp>
#include <connect/ncbi_conn_stream.hpp>
#include <connect/ncbi_file_connector.h>
#include <stdlib.h>

#define NCBI_USE_ERRCODE_X Connect_Stream


BEGIN_NCBI_SCOPE

Expand Down Expand Up @@ -1558,8 +1561,12 @@ extern CConn_IOStream* NcbiOpenURL(const string& url, size_t buf_size)
fHTTP_AutoReconnect,
kDefaultTimeout, buf_size);
case eURL_File:
if (*net_info->host || net_info->port)
if (*net_info->host || net_info->port) {
ERR_POST_X(18, Error << "The limited implementation of the file:// scheme does not"
" support non-empty authority portion of the URL (local files only!)");
break; // not supported
}
_ASSERT(!*net_info->user && !*net_info->pass);
if (net_info->debug_printout) {
// manual cleanup of most fields req'd
net_info->req_method = eReqMethod_Any;
Expand All @@ -1572,8 +1579,6 @@ extern CConn_IOStream* NcbiOpenURL(const string& url, size_t buf_size)
net_info->http_proxy_leak = 0;
net_info->http_proxy_skip = 0;
net_info->http_proxy_mask = 0;
net_info->user[0] = '\0';
net_info->pass[0] = '\0';
net_info->http_proxy_host[0] = '\0';
net_info->http_proxy_port = 0;
net_info->http_proxy_user[0] = '\0';
Expand Down

0 comments on commit 7c909f6

Please sign in to comment.
-