Kaynağa Gözat

关于http请求URI修正

erlArango_v1
AICells 5 yıl önce
ebeveyn
işleme
59ca6b6530
5 değiştirilmiş dosya ile 38 ekleme ve 28 silme
  1. +1
    -1
      include/agHttpCli.hrl
  2. +28
    -18
      src/agApi/agDbMgr.erl
  3. +4
    -4
      src/agHttpCli/agHttpCli.erl
  4. +4
    -4
      src/agHttpCli/agHttpProtocol.erl
  5. +1
    -1
      src/agHttpCli/agMiscUtils.erl

+ 1
- 1
include/agHttpCli.hrl Dosyayı Görüntüle

@ -7,7 +7,7 @@
%% %%
-define(DEFAULT_BASE_URL, <<"http://127.0.0.1:8529">>). -define(DEFAULT_BASE_URL, <<"http://127.0.0.1:8529">>).
-define(DEFAULT_DBNAME, <<"_system">>).
-define(DEFAULT_DBNAME, <<"tttt">>).
-define(DEFAULT_USER, <<"root">>). -define(DEFAULT_USER, <<"root">>).
-define(DEFAULT_PASSWORD, <<"156736">>). -define(DEFAULT_PASSWORD, <<"156736">>).
-define(DEFAULT_BACKLOG_SIZE, 1024). -define(DEFAULT_BACKLOG_SIZE, 1024).

+ 28
- 18
src/agApi/agDbMgr.erl Dosyayı Görüntüle

@ -7,18 +7,28 @@
%% doc_address:https://www.arangodb.com/docs/stable/http/database-database-management.html %% doc_address:https://www.arangodb.com/docs/stable/http/database-database-management.html
%
% /_ap/database/properties
% 使HTTP管理数据库
% ArangoDB用于管理数据库的HTTP接口的简介
% HTTP接口提供创建和删除单个数据库的操作HTTP方法POST DELETEGET方法来检索现有数据库的数组
% _system访访
%
% 使
% 使
% Foxx应用程序也仅在已安装数据库的上下文中可用ArangoDB附带的系统应用程序Web界面访Foxx应用程序则无法访问
%
%
% GET /_api/database/current % GET /_api/database/current
% %
% JSON对象 % JSON对象
% name % name
% idID
% path
% idID()
% path(, mmfiles引擎有效)
% isSystem_system数据库 % isSystem_system数据库
% sharding
% ReplicationFactor
% writeConcern
% sharding()
% ReplicationFactor
% writeConcern
% %
% 200 % 200
% 400 % 400
@ -45,21 +55,21 @@ visitDbs(PoolNameOrSocket) ->
% 400 % 400
% 403_system数据库中执行 % 403_system数据库中执行
allDbs(PoolNameOrSocket) -> allDbs(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/database">>, [], undefined).
agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/database">>, [], undefined, true).
% %
% POST /_api/database % POST /_api/database
% JSON对象是必需的 % JSON对象是必需的
% name
% options
% sharding flexible single
% ReplicationFactor satellite satellite 1
% writeConcernDBServer上同步每个分片需要多少个副本writeConcern的值 ReplicationFactor
% usersusers或不包含任何用户使 root访
% username
% passwd
% activetruefalse
% extraJSON对象Extra中包含的数据 ArangoDB不会进一步解释
% name
% options
% sharding flexible single
% ReplicationFactor satelliteDB-Server1
% writeConcernDB服务器上同步每个分片需要多少个副本writeConcern的值 ReplicationFactorusersusers或不包含任何用户使 root访
% usersusers或不包含任何用户使 root访
% username
% passwd
% activetruefalse
% extraJSON对象Extra中包含的数据 ArangoDB不会进一步解释
% %
% JSON对象true % JSON对象true
% _system数据库中创建新数据库 % _system数据库中创建新数据库

+ 4
- 4
src/agHttpCli/agHttpCli.erl Dosyayı Görüntüle

@ -25,7 +25,7 @@
, connectDb/1 , connectDb/1
, disConnectDb/1 , disConnectDb/1
, getCurDbInfo/1 , getCurDbInfo/1
, setCurDbName/2
, useDatabase/2
]). ]).
@ -264,12 +264,12 @@ setCurDbInfo(Socket, DbName, UserPassword, Host, Protocol) ->
getCurDbInfo(Socket) -> getCurDbInfo(Socket) ->
erlang:get({'$agDbInfo', Socket}). erlang:get({'$agDbInfo', Socket}).
-spec setCurDbName(socket(), binary()) -> ok.
setCurDbName(Socket, NewDbName) ->
-spec useDatabase(socket(), binary()) -> ok.
useDatabase(Socket, NewDbName) ->
case erlang:get({'$agDbInfo', Socket}) of case erlang:get({'$agDbInfo', Socket}) of
undefined -> undefined ->
ignore; ignore;
{_DbName, UserPassword, Host, Protocol} -> {_DbName, UserPassword, Host, Protocol} ->
erlang:put({'$agDbInfo', Socket}, {<<"_db/", NewDbName/binary>>, UserPassword, Host, Protocol})
erlang:put({'$agDbInfo', Socket}, {<<"/_db/", NewDbName/binary>>, UserPassword, Host, Protocol})
end, end,
ok. ok.

+ 4
- 4
src/agHttpCli/agHttpProtocol.erl Dosyayı Görüntüle

@ -15,13 +15,13 @@
-spec request(boolean(), body(), method(), host(), binary(), path(), headers()) -> iolist(). -spec request(boolean(), body(), method(), host(), binary(), path(), headers()) -> iolist().
request(true, undefined, Method, Host, _DbName, Path, Headers) -> request(true, undefined, Method, Host, _DbName, Path, Headers) ->
[ [
Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, <<"_db/_system">>,
Method, <<"/_db/_system">>, Path, <<" HTTP/1.1\r\nHost: ">>, Host,
<<"\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 0\r\n">>, <<"\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 0\r\n">>,
spellHeaders(Headers), <<"\r\n">> spellHeaders(Headers), <<"\r\n">>
]; ];
request(false, undefined, Method, Host, DbName, Path, Headers) -> request(false, undefined, Method, Host, DbName, Path, Headers) ->
[ [
Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, DbName,
Method, DbName, Path, <<" HTTP/1.1\r\nHost: ">>, Host,
<<"\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 0\r\n">>, <<"\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 0\r\n">>,
spellHeaders(Headers), <<"\r\n">> spellHeaders(Headers), <<"\r\n">>
]; ];
@ -29,7 +29,7 @@ request(false, Body, Method, Host, DbName, Path, Headers) ->
ContentLength = integer_to_binary(iolist_size(Body)), ContentLength = integer_to_binary(iolist_size(Body)),
NewHeaders = [{<<"Content-Length">>, ContentLength} | Headers], NewHeaders = [{<<"Content-Length">>, ContentLength} | Headers],
[ [
Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, DbName,
Method, DbName, Path, <<" HTTP/1.1\r\nHost: ">>, Host,
<<"\r\nContent-Type: application/json; charset=utf-8\r\n">>, <<"\r\nContent-Type: application/json; charset=utf-8\r\n">>,
spellHeaders(NewHeaders), <<"\r\n">>, Body spellHeaders(NewHeaders), <<"\r\n">>, Body
]; ];
@ -37,7 +37,7 @@ request(true, Body, Method, Host, _DbName, Path, Headers) ->
ContentLength = integer_to_binary(iolist_size(Body)), ContentLength = integer_to_binary(iolist_size(Body)),
NewHeaders = [{<<"Content-Length">>, ContentLength} | Headers], NewHeaders = [{<<"Content-Length">>, ContentLength} | Headers],
[ [
Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, <<"_db/_system">>,
Method, <<"/_db/_system">>, Path, <<" HTTP/1.1\r\nHost: ">>, Host,
<<"\r\nContent-Type: application/json; charset=utf-8\r\n">>, <<"\r\nContent-Type: application/json; charset=utf-8\r\n">>,
spellHeaders(NewHeaders), <<"\r\n">>, Body spellHeaders(NewHeaders), <<"\r\n">>, Body
]. ].

+ 1
- 1
src/agHttpCli/agMiscUtils.erl Dosyayı Görüntüle

@ -59,7 +59,7 @@ dbOpts(DbCfgs) ->
SocketOpts = ?GET_FROM_LIST(socketOpts, DbCfgs, ?DEFAULT_SOCKET_OPTS), SocketOpts = ?GET_FROM_LIST(socketOpts, DbCfgs, ?DEFAULT_SOCKET_OPTS),
DbOpts = agMiscUtils:parseUrl(BaseUrl), DbOpts = agMiscUtils:parseUrl(BaseUrl),
UserPasswordBase64 = {<<"Authorization">>, <<"Basic ", (base64:encode(<<User/binary, ":", Password/binary>>))/binary>>}, UserPasswordBase64 = {<<"Authorization">>, <<"Basic ", (base64:encode(<<User/binary, ":", Password/binary>>))/binary>>},
DbOpts#dbOpts{dbName = <<"_db/", DbName/binary>>, userPassword = UserPasswordBase64, poolSize = PoolSize, socketOpts = SocketOpts}.
DbOpts#dbOpts{dbName = <<"/_db/", DbName/binary>>, userPassword = UserPasswordBase64, poolSize = PoolSize, socketOpts = SocketOpts}.
-spec agencyOpts(list()) -> agencyOpts(). -spec agencyOpts(list()) -> agencyOpts().
agencyOpts(AgencyCfgs) -> agencyOpts(AgencyCfgs) ->

Yükleniyor…
İptal
Kaydet