aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-04-15 11:41:39 -0400
committerGavin Andresen <gavinandresen@gmail.com>2011-04-15 11:41:39 -0400
commita381eb8ddbad0a6924b856d0025b79562077edfb (patch)
tree1ee5157bac2be75d11325eff0336c42dea275051
parentd7f0287235da6a5c280d5568bf9dbd079a46c28b (diff)
parent17616eac17979ce0b3e0426e7d66ec893a2cb6c6 (diff)
Merge branch 'http-version' of https://github.com/jgarzik/bitcoin
-rw-r--r--init.cpp4
-rw-r--r--rpc.cpp9
-rw-r--r--ui.cpp2
-rw-r--r--util.cpp29
-rw-r--r--util.h9
5 files changed, 38 insertions, 15 deletions
diff --git a/init.cpp b/init.cpp
index effac288fc..906bcbe137 100644
--- a/init.cpp
+++ b/init.cpp
@@ -143,7 +143,7 @@ bool AppInit2(int argc, char* argv[])
{
string beta = VERSION_IS_BETA ? _(" beta") : "";
string strUsage = string() +
- _("Bitcoin version") + " " + FormatVersion(VERSION) + pszSubVer + beta + "\n\n" +
+ _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" +
_("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +
" bitcoin [options] \t " + "\n" +
" bitcoin [options] <command> [params]\t " + _("Send command to -server or bitcoind\n") +
@@ -262,7 +262,7 @@ bool AppInit2(int argc, char* argv[])
if (!fDebug && !pszSetDataDir[0])
ShrinkDebugFile();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- printf("Bitcoin version %s%s%s\n", FormatVersion(VERSION).c_str(), pszSubVer, VERSION_IS_BETA ? _(" beta") : "");
+ printf("Bitcoin version %s\n", FormatFullVersion().c_str());
#ifdef GUI
printf("OS version %s\n", ((string)wxGetOsDescription()).c_str());
printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str());
diff --git a/rpc.cpp b/rpc.cpp
index 93df5c22a4..2570655834 100644
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -1480,7 +1480,7 @@ string HTTPPost(const string& strMsg, const map<string,string>& mapRequestHeader
{
ostringstream s;
s << "POST / HTTP/1.1\r\n"
- << "User-Agent: json-rpc/1.0\r\n"
+ << "User-Agent: bitcoin-json-rpc/" << FormatFullVersion() << "\r\n"
<< "Host: 127.0.0.1\r\n"
<< "Content-Type: application/json\r\n"
<< "Content-Length: " << strMsg.size() << "\r\n"
@@ -1507,7 +1507,7 @@ string HTTPReply(int nStatus, const string& strMsg)
if (nStatus == 401)
return strprintf("HTTP/1.0 401 Authorization Required\r\n"
"Date: %s\r\n"
- "Server: bitcoin-json-rpc\r\n"
+ "Server: bitcoin-json-rpc/%s\r\n"
"WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
"Content-Type: text/html\r\n"
"Content-Length: 296\r\n"
@@ -1520,7 +1520,7 @@ string HTTPReply(int nStatus, const string& strMsg)
"<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>\r\n"
"</HEAD>\r\n"
"<BODY><H1>401 Unauthorized.</H1></BODY>\r\n"
- "</HTML>\r\n", rfc1123Time().c_str());
+ "</HTML>\r\n", rfc1123Time().c_str(), FormatFullVersion().c_str());
string strStatus;
if (nStatus == 200) strStatus = "OK";
else if (nStatus == 400) strStatus = "Bad Request";
@@ -1532,13 +1532,14 @@ string HTTPReply(int nStatus, const string& strMsg)
"Connection: close\r\n"
"Content-Length: %d\r\n"
"Content-Type: application/json\r\n"
- "Server: bitcoin-json-rpc/1.0\r\n"
+ "Server: bitcoin-json-rpc/%s\r\n"
"\r\n"
"%s",
nStatus,
strStatus.c_str(),
rfc1123Time().c_str(),
strMsg.size(),
+ FormatFullVersion().c_str(),
strMsg.c_str());
}
diff --git a/ui.cpp b/ui.cpp
index 45e07d16ea..5d4c6529ff 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -1814,7 +1814,7 @@ void COptionsDialog::OnButtonApply(wxCommandEvent& event)
CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)
{
- m_staticTextVersion->SetLabel(strprintf(_("version %s%s BETA"), FormatVersion(VERSION).c_str(), pszSubVer));
+ m_staticTextVersion->SetLabel(strprintf(_("version %s"), FormatFullVersion().c_str()));
// Change (c) into UTF-8 or ANSI copyright symbol
wxString str = m_staticTextMain->GetLabel();
diff --git a/util.cpp b/util.cpp
index 655626dd3b..1c685ba42d 100644
--- a/util.cpp
+++ b/util.cpp
@@ -855,3 +855,32 @@ void AddTimeData(unsigned int ip, int64 nTime)
printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
}
}
+
+
+
+
+
+
+
+
+
+string FormatVersion(int nVersion)
+{
+ if (nVersion%100 == 0)
+ return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
+ else
+ return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
+}
+
+string FormatFullVersion()
+{
+ string s = FormatVersion(VERSION) + pszSubVer;
+ if (VERSION_IS_BETA)
+ s += _("-beta");
+ return s;
+}
+
+
+
+
+
diff --git a/util.h b/util.h
index 2a7dbb5107..d1754c9e5e 100644
--- a/util.h
+++ b/util.h
@@ -184,6 +184,7 @@ uint64 GetRand(uint64 nMax);
int64 GetTime();
int64 GetAdjustedTime();
void AddTimeData(unsigned int ip, int64 nTime);
+string FormatFullVersion();
@@ -431,14 +432,6 @@ inline bool GetBoolArg(const string& strArg)
return false;
}
-inline string FormatVersion(int nVersion)
-{
- if (nVersion%100 == 0)
- return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
- else
- return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
-}
-