Browse Source

arangoApi 代码添加

erlArango_v1
SisMaker 5 years ago
parent
commit
b670fd2fca
10 changed files with 1387 additions and 13 deletions
  1. +87
    -0
      src/arangoApi/agAnalyzers.erl
  2. +398
    -1
      src/arangoApi/agAqlMod.erl
  3. +123
    -0
      src/arangoApi/agAsyncResultHandling.erl
  4. +162
    -0
      src/arangoApi/agBulkImportExport.erl
  5. +385
    -0
      src/arangoApi/agIndexes.erl
  6. +9
    -0
      src/arangoApi/agSimpleQueries.erl
  7. +7
    -0
      src/arangoApi/agTransactions.erl
  8. +200
    -0
      src/arangoApi/agViews.erl
  9. +12
    -8
      src/httpCli/agHttpCli.erl
  10. +4
    -4
      src/httpCli/agHttpProtocol.erl

+ 87
- 0
src/arangoApi/agAnalyzers.erl View File

@ -0,0 +1,87 @@
-module(agAnalyzers).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/analyzers.html
% HTTP接口
% /_api/analyzer端点访问用于管理ArangoSearch Analyzer的RESTful API
%
%
%
% POST /_api/analyzer
% JSON对象是必需的
% name
% type
% properties
% features
%
%
% 200
% 201
% 400
% 403使
newAnalyzer(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/analyzer">>, [], BodyStr).
%
% GET /_api/analyzer/{analyzer-name}
%
% Analyzer-name
%
%
% type
% properties
%
%
% 200
% 404
getAnalyzer(PoolNameOrSocket, AnalyzerName) ->
Path = <<"/_api/analyzer/", AnalyzerName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_api/analyzer
%
%
% type
% properties
%
%
% 200
getAnalyzerList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/analyzer">>, [], undefined).
%
% DELETE /_api/analyzer/{analyzer-name}
%
% Analyzer-name
%
% 使使false
% analyzer-name标识的Analyzer配置
%
%
% name
%
% 200
% 400
% 403
% 404
% 409使
delAnalyzer(PoolNameOrSocket, AnalyzerName) ->
Path = <<"/_api/analyzer/", AnalyzerName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
delAnalyzer(PoolNameOrSocket, AnalyzerName, IsForce) ->
Path =
case IsForce of
true ->
<<"/_api/analyzer/", AnalyzerName/binary, "?force=true">>;
_ ->
<<"/_api/analyzer/", AnalyzerName/binary>>
end,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).

+ 398
- 1
src/arangoApi/agAqlMod.erl View File

@ -12,4 +12,401 @@
% https://www.arangodb.com/docs/stable/http/aql-query-cursor.html % https://www.arangodb.com/docs/stable/http/aql-query-cursor.html
% AQL User Functions Management: % AQL User Functions Management:
% https://www.arangodb.com/docs/stable/http/aql-query-cursor.html % https://www.arangodb.com/docs/stable/http/aql-query-cursor.html
% AQL操作
% AQL操作
% AQL查询游标的HTTP接口
% ArangoDB查询的HTTP接口的简介AQL的结果和简单查询作为游标返回便
% HTTP POST请求将查询详细信息从客户端传送到服务器
% HTTP访问游标
%
%
% POST /_api/cursor
% JSON对象
% JSON对象是必需的
% query
% count count count count
% batchSize使BATCHSIZE的值 0
% ttl使30
% cache使AQL查询结果缓存的标志false
% memoryLimit使0
% bindVars/
% options/
% FULLCOUNTLIMIT子句 FULLCOUNT{ ... , "extra": { "stats": { "fullCount": 123 } } }FULLCOUNT属性将包含的文档数量的结果应用于在查询的最后顶层限制之前MySQL的SQL_CALC_FOUND_ROWS暗示LIMIT优化使LIMIT子句并且在查询中实际使用LIMIT子句时fullCount属性才可能出现在结果中
% maxPlansAQL查询优化器创建的最大计划数
% maxWarningCount10
% failOnWarningtrue时使false时--query.fail-on-warning用于设置failOnWarning的默认值
% streamtruefalse时arangod实例上API进行访问ttl使使MMFiles上的写锁cachecount并且fullCount不适用于流查询false
% Optimizer
% rules-+all-all禁用所有规则
% profiletrue或1Extra Return属性的子属性配置文件中返回其他查询概要信息2Extra Return属性的子属性stats.nodes中包含每个查询计划节点的执行统计信息extra.plan中返回
% satelliteSyncWaitEnterprise Edition参数允许配置DBServer有多长时间将查询中涉及的附属集合同步60.0
% maxRuntime0.0
% maxTransactionSizeRocksDB存储引擎的尊敬
% middleCommitSizeRocksDB存储引擎的尊敬
% middleCommitCountRocksDB存储引擎的尊敬
% skipInaccessibleCollectionsAQL查询访访AQL查询访访
% POST请求的主体中以JSON表示形式传递
% HTTP 201
% errorfalse
% codeHTTP状态码
% result
% hasMore
% countcount属性的情况下执行的
% idID
% extraJSON对象 extra.stats子属性将包含已修改的文档数和由于错误而无法修改的文档数ignoreErrors查询选项
% cached return属性将不包含任何stats子属性
% JSON格式不正确或请求中缺少查询规范HTTP 400
% JSON格式不正确或请求中缺少查询规范使HTTP 400
% JSON对象
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
% 使HTTP 400
%
% 404访HTTP 404
% 405使HTTP方法HTTP 405
newAqlCursor(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/cursor">>, [], BodyStr).
%
% PUT /_api/cursor/{cursor-identifier}
%
% cursor-identifier
%
% id
%
% hasMorefalse
% count
% 使hasMore返回truehasMore为falsehasMore属性的值为 false
%
% 200HTTP 200
% 400使HTTP 404
% 404使HTTP 404
nextAqlCursor(PoolNameOrSocket, CursorId) ->
Path = <<"/_api/cursor/", (agMiscUtils:toBinary(CursorId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined).
%
% DELETE /_api/cursor/{cursor-identifier}
%
% cursor-identifierID
%
% 使HTTP DELETE请求在任何较早的时间显式销毁游标ID必须作为URL的一部分包含在内
%
%
% 202
% 404404使
delAqlCursor(PoolNameOrSocket, CursorId) ->
Path = <<"/_api/cursor/", (agMiscUtils:toBinary(CursorId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
% AQL查询的HTTP接口
%
%
% ArangoDB有一个HTTP接口AQL查询HTTP接口来检索任何有效AQL查询的执行计划
% AQL查询
% AQL查询
% AQL查询并返回有关它的信息
% POST /_api/explain
% JSON对象
% JSON对象是必需的
% querybindVars中传递options属性中传递查询的其他选项
% bindVars/
% options
% allPlanstruefalse
% maxNumberOfPlans
% Optimizer
% rules-+all-all禁用所有规则
% AQL查询HTTP POST请求将查询字符串发送到服务器
%
% allPlans选项
% warningsstats属性以及一些优化程序统计信息allPlans设置为false 使allPlans
% JSON对象
%
%
% collections使collections
% rules
% variables使
%
% 200使HTTP 200plan属性中返回最佳执行计划allPlansallPlans属性中返回一系列计划
% 400HTTP 400JSON对象中的错误详细信息HTTP 400
% 404访HTTP 404
explainAqlQuery(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/explain">>, [], BodyStr).
% AQL查询并返回有关它的信息
% POST /_api/query
% JSON对象是必需的
% queryHTTP POST请求将查询字符串传递到服务器
% /api/cursor
%
% 200使HTTP 200bindVars属性中返回在查询中找到的绑定参数的名称collections属性中返回查询中使用的collections的数组JSON ast属性将包含查询的抽象语法树表示形式ast的格式在将来的ArangoDB版本中可能会发生变化ArangoDB如何解释给定查询
% 400HTTP 400JSON对象中的错误详细信息
parseAqlQuery(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/query">>, [], BodyStr).
%
% ArangoDB具有HTTP接口AQL查询列表和慢速AQL查询列表使APIHTTP请求的数据库中启用查询跟踪
% AQL查询跟踪的配置
% GET /_api/query/properties
% JSON对象
% enabledtrue false
% trackSlowQueriestrueslowQueryThreshold中设置的值 enabled属性设置为true
% trackBindVarstrue使
% maxSlowQueries
% slowQueryThresholdslowQueryThreshold的值以秒为单位指定
% maxQueryStringLength使使
%
% 200
% 400HTTP 400
getAqlQueryProperties(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/query/properties">>, [], undefined).
% AQL查询跟踪的配置
% PUT /_api/query/properties
% JSON对象是必需的
% enabledtrue false
% trackSlowQueriestrueslowQueryThreshold中设置的值 enabled属性设置为true
% trackBindVarstrue使
% maxSlowQueries
% slowQueryThresholdslowQueryThreshold的值以秒为单位指定
% maxQueryStringLength使使
% HTTP请求主体的属性属性中传递JSON对象
% HTTP响应中返回当前属性集
%
% 200
% 400HTTP 400
changeAqlQueryProperties(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/query/properties">>, [], BodyStr).
% AQL查询的列表
% GET /_api/query/current
% AQL查询JSON对象
% idID
% query
% bindVars使
%
% runTime
% state
% stream使
%
% 200
% 400HTTP 400
getAqlQueryCurrent(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query/current">>, [], undefined).
% AQL查询的列表
% GET /_api/query/slow
% AQL查询maxSlowQueries slowQueryThreshold
% JSON对象
% idID
% query
% bindVars使
%
% runTime
% state
% stream使
%
% 200
% 400HTTP 400
getAqlQuerySlow(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query/slow">>, [], undefined).
% AQL查询列表
% DELETE /_api/query/slow
% AQL查询列表
%
% 200HTTP 200
% 400使HTTP 400
delAqlQuerySlow(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_api/query/slow">>, [], undefined).
% AQL查询
% DELETE /_api/query/{query-id}
%
% query-idID
%
%
% 200HTTP 200
% 400使HTTP 400
% 404ID的查询时HTTP 404
killAqlQuery(PoolNameOrSocket, QueryId) ->
Path = <<"/_api/query/", (agMiscUtils:toBinary(QueryId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
% AQL查询结果缓存的HTTP接口
% AQL查询结果缓存的API方法
% AQL查询结果缓存中存储结果的列表
% GET /_api/query-cache/entries
% AQL查询结果JSON对象
% hash
% query
% bindVars
% size
% /
%
% hits访 0
% runTime
% dataSources使/
%
% 200
% 400HTTP 400
getAqlQueryCaches(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query-cache/entries">>, [], undefined).
% AQL查询结果缓存
% DELETE /_api/query-cache
%
%
% 200HTTP 200
% 400使HTTP 400
clearAqlQueryCaches(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_api/query-cache">>, [], undefined).
% AQL查询结果缓存的全局配置
% GET /_api/query-cache/properties
% AQL查询结果缓存配置JSON对象
% modeAQL查询结果缓存运行的模式offon或demand
% maxResults
% maxResultsSize
% maxEntrySize
% includeSystem
%
% 200
% 400HTTP 400
getAqlQueryCacheProperties(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query-cache/properties">>, [], undefined).
% AQL查询结果缓存的配置
% PUT /_api/query-cache/properties
% JSON对象是必需的
% modeAQL查询缓存应以哪种模式运行offon或demand
% maxResults
% maxResultsSize
% maxEntrySize
% includeSystem
% HTTP响应中返回当前属性集
% 使AQL查询缓存的全局属性HTTP请求主体的属性属性中传递JSON对象
%
% 200
% 400HTTP 400
changeAqlQueryCacheProperties(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query-cache/properties">>, [], BodyStr).
% AQL用户功能管理的HTTP接口
% AQL用户功能管理
% AQL用户功能的ArangoDB HTTP接口的简介AQL用户功能是一种使用用户定义的JavaScript代码扩展ArangoDB查询语言AQL
%AQL用户功能及其含义的概述 AQL
%HTTP接口提供用于添加AQL用户功能的API
%_aqlfunctions中访访
% AQL用户功能
% AQL用户功能
% POST /_api/aqlfunction
% JSON对象是必需的
% name
% code
% isDeterministicisDeterministic属性是当前未使用但对于优化可以在以后使用
%
% HTTP 200
% HTTP 400
% HTTP 200使HTTP 200
% errorfalse
% codeHTTP状态码
% isNewlyCreatedfalse
% HTTP 201使HTTP 201
% errorfalse
% codeHTTP状态码
% isNewlyCreatedtrue
% HTTP 400JSON格式不正确或请求中缺少必需数据使HTTP 400
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
newAqlUserFun(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/aqlfunction">>, [], BodyStr).
% AQL用户功能
% DELETE /_api/aqlfunction/{name}
%
% AQL用户功能的名称
%
% - 0
% HTTP 404
% name标识的现有AQL用户功能或功能组
% HTTP 200使HTTP 200
% errorfalse
% codeHTTP状态码
% DeleteCount1group设置为false时true>= 0group
% HTTP 400使HTTP 400
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
% HTTP 404使HTTP 404
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
delAqlUserFun(PoolNameOrSocket, UserFunName) ->
Path = <<"/_api/aqlfunction/", (agMiscUtils:toBinary(UserFunName))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
% AQL用户功能
% GET /_api/aqlfunction
%
% namespaceresult下的命名空间namespace返回所有已注册的AQL用户函数
% AQL用户功能
% JSON数组result下找到的所有用户函数
% HTTP 200HTTP 200
% errorfalse
% codeHTTP状态码
%
% name
% code
% isDeterministicisDeterministic属性是当前未使用但对于优化可以在以后使用
% HTTP 400使HTTP 400
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
getAqlUserFuns(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/aqlfunction">>, [], undefined).
getAqlUserFuns(PoolNameOrSocket, Namespace) ->
Path = <<"/_api/aqlfunction?namespace=", (agMiscUtils:toBinary(Namespace))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).

+ 123
- 0
src/arangoApi/agAsyncResultHandling.erl View File

@ -0,0 +1,123 @@
-module(agAsyncResultHandling).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/async-results-management.html
% HTTP接口
%
% ArangoDB提供了执行客户端请求的各种方法
%
% ArangoDB是多线程服务器线
% ArangoDB
% 线
% 使HTTP连接 HttpJobPutCancel下的内容
%
% 1.4使ArangoDBHTTP标头x-arango-asynctrueArangoDB会将请求放入内存任务队列中HTTP请求返回HTTP 202
% HTTP 202
%
%
% --server.maximal-queue-size确定HTTP 500
% 使 HttpJobPutCancel
%
% HTTP标头x-arango-asyncArangoDB服务器如上所述异步执行操作HTTP响应标头x-arango-async-id中返回作业IDID与/ _api / job上的HTTP API结合使用
% API询问ArangoDB服务器ID传递给异步作业APIID取消运行异步作业HttpJobPutCancel
% ArangoDB将保留通过x-arango-async
% API还提供了用于垃圾回收的方法使ArangoDB不会人为地限制尚未获取的结果的数量
%
%
%
% 使ID取消异步运行的作业HttpJobPutCancel中所述PUT请求
% C ++JavaScript代码执行CRUD操作直接在C ++AQL查询和事务由JavaScript代码执行JavaScript代码使JavaScript线程中触发不可捕获的异常C ++
% DB-Server的任务
%
%
% HTTP
%
%
% PUT /_api/job/{job-id}
%
% job-idID
% job-id标识的异步作业的结果job-id调用一次此方法HTTP标头x-arango-async-job-id
%
% 204job-id请求的作业仍在待处理x-arango-async-id HTTP标头
% 400IDx-arango-async-id HTTP标头
% 404404x-arango-async-id HTTP标头
getAsyncJobRet(PoolNameOrSocket, JodId) ->
Path = <<"/_api/job/", (agMiscUtils:toBinary(JodId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined).
%
% PUT /_api/job/{job-id}/cancel
%
% job-idID
% ID标识的当前正在运行的作业
%
% 200
% 400IDx-arango-async-id HTTP标头
% 404404x-arango-async-id HTTP标头
cancelAsyncJob(PoolNameOrSocket, JodId) ->
Path = <<"/_api/job/", (agMiscUtils:toBinary(JodId))/binary, "/cancel">>,
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined).
%
% DELETE /_api/job/{type}#by-type
%
% type
% all
% expiredstamp必须是UNIX时间戳
% ID
%
% UNIX时间戳记
% 使
%
% 200
% 400type或值无效
% 404type为job-idid的异步作业404
delAsyncJobRet(PoolNameOrSocket, TypeOrJodId, Stamp) ->
Path =
case TypeOrJodId of
<<"expired">> ->
<<"/_api/job/expired?stamp=", (agMiscUtils:toBinary(Stamp))/binary>>;
_ ->
<<"/_api/job/", (agMiscUtils:toBinary(TypeOrJodId))/binary>>
end,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
%
% GET /_api/job/{job-id}
%
% job-idID
% HTTP响应代码来确定处理状态
%
% 200job-id请求的作业200
% 204job-id请求的作业仍在待处理
% 404404
getAsyncJobStatus(PoolNameOrSocket, JodId) ->
Path = <<"/_api/job/", (agMiscUtils:toBinary(JodId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
% ID
% GET /_api/job/{type}#by-type
%
% typedone将使该方法返回可以获取其结果的异步作业的IDID
%
% countID数使
% ID列表使
%
% 200
% 400type或值无效
getAsyncJobList(PoolNameOrSocket, Type) ->
Path = <<"/_api/job/", (agMiscUtils:toBinary(Type))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
getAsyncJobList(PoolNameOrSocket, Type, Count) ->
Path = <<"/_api/job/", (agMiscUtils:toBinary(Type))/binary, "?count=", (agMiscUtils:toBinary(Count))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).

+ 162
- 0
src/arangoApi/agBulkImportExport.erl View File

@ -0,0 +1,162 @@
-module(agBulkImportExport).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/bulk-imports.html
% HTTP接口
% ArangoDB提供了一个HTTP接口
% JSON格式提供
% JSON文档
%
% / _api / import使HTTP POST请求将数据发送到此URLPOST请求的正文中
%
% waitForSync查询参数设置为true
% complete查询参数设置为true使使
% complete具有除true以外的其他值
% details查询参数设置为true使API返回有关无法导入的文档的详细信息details为truedetails属性false或省略
%
% JSON编码的列表中导入文档
% POST /_api/import#document
%
%
% fromPrefix_from属性中值的可选前缀_from输入值之前_from
% toPrefix_to属性中值的可选前缀_to输入值之前_to
% true或yes
% waitForSync
% onDuplicate
%
% update使
% replace
% ignore
% _key属性时updatereplace和ignore才起作用
% true或yes使使
% detailstrue或yesdetails
%
% JSON编码的属性值数组组成JSON编码的属性名称数组
% collection-nameJSON编码的属性名称数组JSON编码的属性值数组
% JSON对象
% created
% errors
% emptydocuments或只能包含大于零的值auto
% updated/onDuplicate update或replace
% ignored onDuplicate设置为ignore
% detailsdetails设置为truedetails属性
%
% 201
% 400type包含无效值collection指定no
% 404collection或导入边的_from或_to属性引用未知集合
% 409complete则返回 true
% 500500
importFormDocument(PoolNameOrSocket, ListOfList, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/import", QueryBinary/binary>>,
BodyStr = jiffy:encode(ListOfList),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).
% JSON
% POST /_api/import#json
%
% type可以具有以下值
% documents使JSON编码的文档JSON对象需要用换行符分隔
% list使JSON编码数组
% auto documents或list
%
% fromPrefix_from属性中值的可选前缀_from输入值之前_from
% toPrefix_to属性中值的可选前缀_to输入值之前_to
% true或yes
% waitForSync
%
% update使
% replace
% ignore
% _key属性时updatereplace和ignore才起作用
% true或yes使使
% detailstrue或yesdetails
%
% JSON编码的对象数组JSON对象的字符串
% collection-nameJSON表示形式必须作为POST请求的主体传递JSON对象JSON数组
% JSON对象
% created
% errors
% emptydocuments或只能包含大于零的值auto
% updated/onDuplicate update或replace
% ignored onDuplicate设置为ignore
% detailsdetails设置为truedetails属性
%
% 201
% 400type包含无效值collection指定no
% 404collection或导入边的_from或_to属性引用未知集合
% 409complete则返回 true
% 500500
importFormJson(PoolNameOrSocket, MapDataList, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/import", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapDataList),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).
% HTTP接口
% HTTP请求中向ArangoDB发送单独的操作
% ArangoDB提供了一个批处理请求API使API批量向ArangoDB发送多个操作/HTTP请求并且各个请求的结果彼此不依赖时
% URL / _api / batch处理程序发出多部分HTTP POST请求来使用ArangoDB的批处理API Content-type为multipart / form-dataArangoDB将使用此边界将批处理请求分解为各个部分ArangoDB将多部分请求分为其各个部分时ArangoDB将生成一个多部分HTTP响应5ArangoDB还将发送包含5个部分的多部分响应
%
% Content-type: application/x-arango-batchpart
% Content-Id Content-IdContent-IdContent-Id的唯一性Content-type和可选Content-Id标头之后Windows换行符\ r \ n \ r \ nHTTP请求Windows换行符
% Content-typeapplication / x-arango-batchpart是MIME部分的标头HTTP请求MIME部分的正文部分
% HTTP方法URL和HTTP协议版本开头HTTP标头\ r \ n \ r \ n HTTP请求
% 3使 XXXsubpartXXX
% *******************************************************************
% HTTP接口
% *******************************************************************
% HTTP接口
%
% 使
% POST /_api/export
%
%
% JSON对象是必需的
% flushtrueWAL刷新操作WAL复制到集合的数据文件中flushWait秒的额外等待时间使WAL收集器也可以更改调整后的文档元数据以指向数据文件false
% flushWait10flush设置为true时
% count count count count
% batchSize使
% limitlimit属性或将其设置为0将导致不使用任何限制使
% ttl使
%
% 使
%
% API相比API生成的内部数据结构更轻便
% /_api/cursorREST API中相似的方式返回文档hasMore属性将设置为 falsehasMore属性将设置为trueid属性将包含游标id
% 退
% WAL
% API或设置flush属性之前发出WAL刷新请求 WAL冲洗便WAL复制到集合数据文件
% 使HTTP 201 JSON对象
% JSON对象具有以下属性
% false
% codeHTTP状态码
% result
% hasMore
% countcount属性的情况下执行的
% idID
% JSON格式不正确或请求中缺少查询规范使HTTP 400
% JSON对象
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
% 使ttl值来调整此空闲时间
% API
%
% 201
% 400JSON表示格式错误或请求中缺少查询规范
% 404访HTTP 404
% 405使HTTP方法HTTP 405
% 501API使HTTP 501
% CousurId newAqlCursor
exportDocuments(PoolNameOrSocket, CollName, MapData) ->
Path = <<"/_api/export?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).

+ 385
- 0
src/arangoApi/agIndexes.erl View File

@ -0,0 +1,385 @@
-module(agIndexes).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/indexes.html
% HTTP接口
%
% ArangoDB索引的HTTP接口的一般介绍
%
% 访_key属性 _from和_to属性快速访问文档
%
% _id键不支持用户创建的任何索引
%
% /访
%
% _keysystem属性中_key和_id属性的查询
%
%
%
%
%
%
%
%
% TTL
% TTL索引可用于自动从集合中删除过期的文档线
%
% 使libicu提供的单词边界分析来完成单词标记化
%
% ArangoDB中的所有索引都有唯一的句柄ArangoDB管理URI下找到
% http://server:port/_api/index/index-handle
% demo / 63563528URL为
% http://localhost:8529/_api/index/demo/63563528
% 使HTTP使用索引
%
% GET /_api/index/{index-id}
%
% index-id
%
% id
% type
% selectivityEstimate属性中提供了选择性估计
%
% 200HTTP 200
% 404 HTTP 404
getIndexInfo(PoolNameOrSocket, IndexId) ->
Path = <<"/_api/index/", (agMiscUtils:toBinary(IndexId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
%
% POST /_api/index#general
%
%
% json
% collection中创建一个新索引
% type属性中指定要创建的索引的类型
% fields属性中的被索引属性
% _id使_id作为索引属性手动创建索引将失败
% name属性中指定为字符串
% true将创建唯一索引false或忽略unique属性将创建一个非唯一索引
% 使unique属性可能会导致错误
%
%
%
% sparse属性设置为truenull的文档
% hash或skiplist的数组索引支持可选的重复数据删除属性true
%
% 200HTTP 200
% 201 HTTP 201
% 400使HTTP 400
% 404HTTP 404
newIndex(PoolNameOrSocket, CollName, MapData) ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).
%
% DELETE /_api/index/{index-id}
%
% index-idID
% index-id的索引
%
% 200HTTP 200
% 404index-id未知HTTP 404
delIndex(PoolNameOrSocket, IndexId) ->
Path = <<"/_api/index/", (agMiscUtils:toBinary(IndexId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
%
% GET /_api/index
%
%
% 使
%
% 200JSON对象
getIndexList(PoolNameOrSocket, CollName) ->
Path = <<"/_api/index", CollName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
% 使
% /_api/simple/by-example则将使用该索引执行示例查询
%
% POST /_api/index#hash
%
%
% JSON对象是必需的
% hash
%
% uniquetrue
% sparsetrue
% false
% collection-name创建哈希索引
% fieldnull的文档将从索引中排除
% 使null值
%
%
% 200HTTP 200
% 201 HTTP 201
% 400使HTTP 400
% 404HTTP 404
newIndexOfHash(PoolNameOrSocket, CollName, MapData) ->
case MapData of
#{<<"type">> := <<"hash">>} ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr);
_ ->
{error, param}
end.
%
% PUT /_api/simple/by-example
% 使3.4.0使AQL查询取代
% ArangoDB版本3.2.133.3.7API相当昂贵使HTTP Cursor API3.2.143.3.8API的内部实现已更改
% JSON对象是必需的
% collection
% example
% skip
% limit
% batchSize使BATCHSIZE的值 0
%
% HTTP Cursor
%
% 201
% 400JSON表示形式
% 404collection指定的collection未知
%
% PUT /_api/simple/first-example
% 使3.4.0使AQL查询取代
% ArangoDB版本3.2.133.3.7API相当昂贵使HTTP Cursor API3.2.143.3.8API的内部实现已更改
% JSON对象是必需的
% collection
% example
%
% HTTP 404
%
%
% 200
% 400JSON表示形式
% 404collection指定的collection未知
% 使
% /_api/simple/range其他操作将使用该索引来执行查询
%
% POST /_api/index#skiplist
%
%
% JSON对象是必需的
% skiplist
%
% uniquetrue
% sparsetrue
% false
% collection-name创建一个跳过列表索引
% fieldnull的文档将从索引中排除
% 使null值
%
%
% 200HTTP 200
% 201 HTTP 201
% 400HTTP 400
% 404HTTP 404
newIndexOfSkipList(PoolNameOrSocket, CollName, MapData) ->
case MapData of
#{<<"type">> := <<"skiplist">>} ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr);
_ ->
{error, param}
end.
% 使
% /_api/simple/range其他操作将使用该索引执行查询
%
%
% POST /_api/index#persistent
%
%
% JSON对象是必需的
% persistent
%
% uniquetrue
% sparsetrue
% collection-name创建一个持久索引
% fieldnull的文档将从索引中排除
% 使null值
%
%
% 200HTTP 200
% 201 HTTP 201
% 400HTTP 400
% 404HTTP 404
newIndexOfPersistent(PoolNameOrSocket, CollName, MapData) ->
case MapData of
#{<<"type">> := <<"persistent">>} ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr);
_ ->
{error, param}
end.
% 使TTL
%
% TTL
% POST /_api/index#ttl
%
%
% JSON对象是必需的
% ttl
% fields
% expireAfter
% collection-name创建TTL索引
%
% 200HTTP 200
% 201 HTTP 201
% 400TTL索引HTTP 400TTL索引
% 404HTTP 404
newIndexOfTtl(PoolNameOrSocket, CollName, MapData) ->
case MapData of
#{<<"type">> := <<"ttl">>} ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr);
_ ->
{error, param}
end.
% 使
%
%
% POST /_api/index#geo
%
%
% JSON对象是必需的
% geo
%
% location的数组使location作为坐标的路径在所有文档上创建地理空间索引double值的数组
% latitude和经度的数组使
% geoJsongeoJson为truehttp://geojson.org/geojson-spec.html#positions中描述的格式
% collection-name中创建地理空间索引
%
%
% 200HTTP 200
% 201 HTTP 201
% 404HTTP 404
newIndexOfGeo(PoolNameOrSocket, CollName, MapData) ->
case MapData of
#{<<"type">> := <<"geo">>} ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr);
_ ->
{error, param}
end.
%
%PUT /_api/simple/near
%使3.4.0使AQL查询取代
%JSON对象是必需的
%collection
%latitude
%
%distance
%skip
%limit100
%geo使
%100
%使Near运算符使geo字段来选择特定的索引
%HTTP Cursor
%ArangoDB 2.6使ArangoDB版本中可能会删除此API使Near运算符从集合中检索文档的首选方法是使用NEAR函数发出AQL查询
%FOR doc IN NEAR(@@collection, @latitude, @longitude, @limit)
%RETURN doc`
%
%201
%400JSON表示形式
%404collection指定的collection未知
%
%
% PUT /_api/simple/within
% 使3.4.0使AQL查询取代
% JSON对象是必需的
% collection
% latitude
%
% radius
% distance
% limit100
% geo使
%
% 使使geo字段来选择特定的索引
% HTTP Cursor
% ArangoDB 2.6使ArangoDB版本中可能会删除此API使Near运算符从集合中检索文档的首选方法是使用WITHIN函数发出AQL查询
% FOR doc IN WITHIN(@@collection, @latitude, @longitude, @radius, @distanceAttributeName)
% RETURN doc
%
% 201
% 400JSON表示形式
% 404collection指定的collection未知
%
% /_api/simple/fulltext则将使用该索引执行指定的全文查询
%
%
%
% POST /_api/index#fulltext
%
%
% JSON对象是必需的
% fulltext
%
% minLength
% collection-name创建全文索引
%
% 200HTTP 200
% 201 HTTP 201
% 404HTTP 404
newIndexOfFulltext(PoolNameOrSocket, CollName, MapData) ->
case MapData of
#{<<"type">> := <<"fulltext">>} ->
Path = <<"/_api/index?collection=", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr);
_ ->
{error, param}
end.
%
%
% PUT /_api/simple/fulltext
% 使3.4.0使AQL查询取代
% JSON对象是必需的
% collection
% attribute
%
% skip
% limit
% index使
%
% 使
% HTTP Cursor
% ArangoDB 2.6使ArangoDB版本中可能会删除此API使Near运算符从集合中检索文档的首选方法是使用FULLTEXT AQL函数发出AQL查询
% FOR doc IN FULLTEXT(@@collection, @attributeName, @queryString, @limit)
% RETURN doc
%
% 201
% 400JSON表示形式
% 404collection指定的collection未知

+ 9
- 0
src/arangoApi/agSimpleQueries.erl View File

@ -0,0 +1,9 @@
-module(agSimpleQueries).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/simple-query.html
% 3.4.0使API使AQL查询取代

+ 7
- 0
src/arangoApi/agTransactions.erl View File

@ -0,0 +1,7 @@
-module(agTransactions).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/transaction.html

+ 200
- 0
src/arangoApi/agViews.erl View File

@ -0,0 +1,200 @@
-module(agViews).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/views.html
% ArangoSearch视图
% ArangoSearch视图
% POST /_api/view#arangosearch
% JSON对象是必需的
% name
% type arangosearch
% links ArangoSearch查看链接属性
% primarySortAQL优化View的所有文档primarySort定义匹配SORT操作将被优化
% "asc升序,"desc"降序): [ { "field": "attr", "direction": "asc"}, … ]
% cleanupIntervalStepArangoSearch数据目录中的未使用文件之间至少等待这么多次提交2使0commit + consolidate/
% View内部数据结构的新状态//
% commitIntervalMsecView数据存储更改和使文档对查询可见之前1000使0/使/
% ArangoSearch视图遵循ArangoDB中的所有数据将通过相应的查询表达式进行匹配ArangoSearch View//ArangoDB事务中调用的查询反映ArangoDB事务仍将继续返回可重复读取状态
% integrationIntervalMsec'consolidationPolicy'View数据存储与可能释放文件系统上的空间之间至少等待这么多毫秒10000使0使
% ArangoSearch视图遵循 consolidationIntervalMsec consolidationPolicy
% consolidationPolicy{}
% ArangoDB交易进行的插入文档的一个或多个ArangoSearch内部段被创建使使
%
% type
% "tier"使segments*minScore属性可用
% "bytes_accum" {threshold} > (segment_bytes + sum_of_merge_candidate_segment_bytes) / all_segment_bytes {threshold}使threshold属性可用
% threshold[0.0, 1.0]
% segmentsBytesFloor2097152
% segmentsBytesMax5368709120
% segmentsMax10
% segmentsMin1
% minScore0
% writebufferIdle64使0
% writebufferActive0使0
% writebufferSizeMax0value会关闭所有写入器线ArangoDB服务器启动选项0使33554432使0
%
%
% 400name或type属性丢失或无效 HTTP 400
% 409name的视图HTTP 409
newViewOfArangoSearch(PoolNameOrSocket, MapData) ->
case MapData of
#{<<"type">> := <<"arangosearch">>} ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/view">>, [], BodyStr);
_ ->
{error, param}
end.
%
% GET /_api/view/{view-name}
%
% view-name
%
% id
% name
% type
%
% 404HTTP 404
getViewInfo(PoolNameOrSocket, ViewName) ->
Path = <<"/_api/view/", ViewName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_api/view/{view-name}/properties
%
% view-name
% view-name标识的View的定义
%
%
% 400HTTP 400
% 404HTTP 404
getViewProperties(PoolNameOrSocket, ViewName) ->
Path = <<"/_api/view/", ViewName/binary, "/properties">>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_api/view
%
% ID
%
%
%
% 200
getViewList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/view">>, [], undefined).
% ArangoSearch视图的所有属性
%
% PUT /_api/view/{view-name}/properties#ArangoSearch
%
% view-name
% JSON对象是必需的
% links ArangoSearch查看链接属性
% cleanupIntervalStepArangoSearch数据目录中的未使用文件之间至少等待这么多次提交2使0commit + consolidate/
% View内部数据结构的新状态//
% commitIntervalMsecView数据存储更改和使文档对查询可见之前1000使0/使/
% ArangoSearch视图遵循ArangoDB中的所有数据将通过相应的查询表达式进行匹配ArangoSearch View//ArangoDB事务中调用的查询反映ArangoDB事务仍将继续返回可重复读取状态
% integrationIntervalMsec'consolidationPolicy'View数据存储与可能释放文件系统上的空间之间至少等待这么多毫秒10000使0使
% ArangoSearch视图遵循 consolidationIntervalMsec consolidationPolicy
% consolidationPolicy{}
% ArangoDB交易进行的插入文档的一个或多个ArangoSearch内部段被创建使使
%
% type
% "tier"使segments * minScore属性可用
% "bytes_accum" {threshold} > (segment_bytes + sum_of_merge_candidate_segment_bytes) / all_segment_bytes {threshold}使threshold属性可用
% threshold[0.0, 1.0]
% segmentsBytesFloor2097152
% segmentsBytesMax5368709120
% segmentsMax10
% segmentsMin1
% minScore0
%
%
% id
% name
% type
% ArangoSearch View实施特定的属性
%
% 400HTTP 400
% 404HTTP 404
changeViewAllProperties(PoolNameOrSocket, ViewName, MapData) ->
Path = <<"/_api/view/", ViewName/binary, "/properties">>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
% ArangoSearch视图的属性
% PATCH /_api/view/{view-name}/properties#ArangoSearch
%
% view-name
%
% links ArangoSearch查看链接属性
% cleanupIntervalStepArangoSearch数据目录中的未使用文件之间至少等待这么多次提交2使0commit + consolidate/
% View内部数据结构的新状态//
% commitIntervalMsecView数据存储更改和使文档对查询可见之前1000使0/使/
% ArangoSearch视图遵循ArangoDB中的所有数据将通过相应的查询表达式进行匹配ArangoSearch View//ArangoDB事务中调用的查询反映ArangoDB事务仍将继续返回可重复读取状态
% integrationIntervalMsec'consolidationPolicy'View数据存储与可能释放文件系统上的空间之间至少等待这么多毫秒10000使0使
% ArangoSearch视图遵循 consolidationIntervalMsec consolidationPolicy
% consolidationPolicy{}
% ArangoDB交易进行的插入文档的一个或多个ArangoSearch内部段被创建使使
%
% type
% "tier"使segments * minScore属性可用
% "bytes_accum" {threshold} > (segment_bytes + sum_of_merge_candidate_segment_bytes) / all_segment_bytes {threshold}使threshold属性可用
% threshold[0.0, 1.0]
% segmentsBytesFloor2097152
% segmentsBytesMax5368709120
% segmentsMax10
% segmentsMin1
% minScore0
%
%
% id
% name
% type
% ArangoSearch View实施特定的属性
%
% 400HTTP 400
% 404HTTP 404
changeViewPartProperties(PoolNameOrSocket, ViewName, MapData) ->
Path = <<"/_api/view/", ViewName/binary, "/properties">>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr).
%
% PUT /_api/view/{view-name}/rename
%
% view-nameView的名称
%
%
%
% id
% name
% type
%
%
% 400HTTP 400
% 404HTTP 404
renameView(PoolNameOrSocket, ViewName, NewViewName) ->
Path = <<"/_api/view/", ViewName/binary, "/rename">>,
NameStr = jiffy:encode(NewViewName),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], <<"{\"name\":", NameStr/binary, "}">>).
%
% DELETE /_api/view/{view-name}
%
% view-name
% view-name标识的View
% View
%
% id
%
% 400HTTP 400
% 404HTTP 404
delView(PoolNameOrSocket, ViewName) ->
Path = <<"/_api/view/", ViewName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).

+ 12
- 8
src/httpCli/agHttpCli.erl View File

@ -14,7 +14,7 @@
, castAgency/6 , castAgency/6
, castAgency/7 , castAgency/7
, castAgency/8 , castAgency/8
, receiveResponse/1
, receiveResponse/2
%% API %% API
, startPool/2 , startPool/2
@ -40,8 +40,8 @@ callAgency(PoolNameOrSocket, Method, Path, Headers, Body, IsSystem) ->
-spec callAgency(poolNameOrSocket(), method(), path(), headers(), body(), boolean(), timeout()) -> term() | {error, atom()}. -spec callAgency(poolNameOrSocket(), method(), path(), headers(), body(), boolean(), timeout()) -> term() | {error, atom()}.
callAgency(PoolNameOrSocket, Method, Path, Headers, Body, IsSystem, Timeout) -> callAgency(PoolNameOrSocket, Method, Path, Headers, Body, IsSystem, Timeout) ->
case castAgency(PoolNameOrSocket, Method, Path, Headers, Body, self(), IsSystem, Timeout) of case castAgency(PoolNameOrSocket, Method, Path, Headers, Body, self(), IsSystem, Timeout) of
{ok, RequestId} ->
receiveResponse(RequestId);
{ok, RequestId, MonitorRef} ->
receiveResponse(RequestId, MonitorRef);
{error, _Reason} = Err -> {error, _Reason} = Err ->
Err; Err;
Ret -> Ret ->
@ -76,9 +76,10 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout
undefined -> undefined ->
{error, undefined_server}; {error, undefined_server};
AgencyName -> AgencyName ->
RequestId = {AgencyName, make_ref()},
MonitorRef = erlang:monitor(process, AgencyName),
RequestId = {AgencyName, MonitorRef},
catch AgencyName ! #miRequest{method = Method, path = Path, headers = Headers, body = Body, requestId = RequestId, fromPid = Pid, overTime = OverTime, isSystem = IsSystem}, catch AgencyName ! #miRequest{method = Method, path = Path, headers = Headers, body = Body, requestId = RequestId, fromPid = Pid, overTime = OverTime, isSystem = IsSystem},
{ok, RequestId}
{ok, RequestId, MonitorRef}
end; end;
_ -> _ ->
case getCurDbInfo(PoolNameOrSocket) of case getCurDbInfo(PoolNameOrSocket) of
@ -124,11 +125,14 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout
end end
end. end.
-spec receiveResponse(requestId()) -> term() | {error, term()}.
receiveResponse(RequestId) ->
-spec receiveResponse(requestId(), reference()) -> term() | {error, term()}.
receiveResponse(RequestId, MonitorRef) ->
receive receive
#miAgHttpCliRet{requestId = RequestId, reply = Reply} -> #miAgHttpCliRet{requestId = RequestId, reply = Reply} ->
Reply
erlang:demonitor(MonitorRef),
Reply;
{'DOWN', MonitorRef, process, _Pid, Reason} ->
{error, {agencyDown, Reason}}
end. end.
-spec receiveTcpData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> requestRet() | {error, term()}. -spec receiveTcpData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> requestRet() | {error, term()}.

+ 4
- 4
src/httpCli/agHttpProtocol.erl View File

@ -59,7 +59,7 @@ response(undefined, Rn, RnRn, Data, IsHeadMethod) ->
{0, Headers, Rest} -> {0, Headers, Rest} ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}};
{chunked, Headers, Body} -> {chunked, Headers, Body} ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &gt;= 100 andalso StatusCode < 200) of
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &lt; 200 andalso StatusCode >= 100) of
true -> true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}};
_ -> _ ->
@ -75,7 +75,7 @@ response(undefined, Rn, RnRn, Data, IsHeadMethod) ->
?WARN(agTcpAgencyIns, "11 contentLength get to long data why? more: ~p ~n", [BodySize - ContentLength]), ?WARN(agTcpAgencyIns, "11 contentLength get to long data why? more: ~p ~n", [BodySize - ContentLength]),
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}};
true -> true ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &gt;= 100 andalso StatusCode < 200) of
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &lt; 200 andalso StatusCode >= 100) of
true -> true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}};
_ -> _ ->
@ -126,7 +126,7 @@ response(#recvState{stage = header, body = OldBody}, Rn, RnRn, Data, IsHeadMetho
{0, Headers, Body} -> {0, Headers, Body} ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Body}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Body}};
{chunked, Headers, Rest} -> {chunked, Headers, Rest} ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &gt;= 100 andalso StatusCode < 200) of
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &lt; 200 andalso StatusCode >= 100) of
true -> true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}};
_ -> _ ->
@ -142,7 +142,7 @@ response(#recvState{stage = header, body = OldBody}, Rn, RnRn, Data, IsHeadMetho
?WARN(agTcpAgencyIns, "33 contentLength get to long data why? more: ~p ~n", [BodySize - ContentLength]), ?WARN(agTcpAgencyIns, "33 contentLength get to long data why? more: ~p ~n", [BodySize - ContentLength]),
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}};
true -> true ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &gt;= 100 andalso StatusCode < 200) of
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode &lt; 200 andalso StatusCode >= 100) of
true -> true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}}; {done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}};
_ -> _ ->

Loading…
Cancel
Save