Should throw exception and not retry when the request is not repeatable
vivekmuniyandi opened this issue · 3 comments
vivekmuniyandi commented
When the request itself is not repeatable (let's say if the body's request is a stream), we should throw an exception when we get a 401 and not retry the request. For example see this request and response. The body is not repeatable.
PUT /v1/ext/test/evaltest.xqy HTTP/1.1
ML-Agent-ID: java
Content-Type: text/plain
Transfer-Encoding: chunked
Host: 192.168.0.39:8012
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.6.0
8d3
declare namespace test='http://marklogic.com/test';
declare variable $test:myString as xs:string external;
declare variable $myArray as json:array external;
declare variable $myObject as json:object external;
declare variable $myAnyUri as xs:anyURI external;
declare variable $myBinary as binary() external;
declare variable $myBase64Binary as xs:base64Binary external;
declare variable $myHexBinary as xs:hexBinary external;
declare variable $myDuration as xs:duration external;
declare variable $myQName as xs:QName external;
declare variable $myDocument as document-node() external;
declare variable $myComment as document-node() external;
(: declare variable $myComment as comment() external; :)
declare variable $myElement as element() external;
declare variable $myProcessingInstruction as document-node() external;
declare variable $myText as text() external;
declare variable $myBool as xs:boolean external;
declare variable $myInteger as xs:integer external;
declare variable $myBigInteger as xs:string external;
declare variable $myDecimal as xs:decimal external;
declare variable $myDouble as xs:double external;
declare variable $myFloat as xs:float external;
declare variable $myGDay as xs:gDay external;
declare variable $myGMonth as xs:gMonth external;
declare variable $myGMonthDay as xs:gMonthDay external;
declare variable $myGYear as xs:gYear external;
declare variable $myGYearMonth as xs:gYearMonth external;
declare variable $myDate as xs:date external;
declare variable $myDateTime as xs:dateTime external;
declare variable $myTime as xs:time external;
let $myAttribute := $myElement/@*
let $myComment := $myComment/comment()
let $myProcessingInstruction := $myProcessingInstruction/processing-instruction()
let $myCtsQuery := cts:word-query('a')
let $myFunction := xdmp:functions()[2]
return (
$test:myString, $myArray, $myObject, $myAnyUri,
$myBinary, $myBase64Binary, $myHexBinary, $myDuration, $myQName,
$myDocument, $myAttribute, $myComment, $myElement, $myProcessingInstruction, $myText,
$myBool, $myInteger, $myBigInteger, $myDecimal, $myDouble, $myFloat,
$myGDay, $myGMonth, $myGMonthDay, $myGYear, $myGYearMonth, $myDate, $myDateTime, $myTime,
$myCtsQuery, $myFunction
)
0
HTTP/1.1 401 Unauthorized
Server: MarkLogic
WWW-Authenticate: Digest realm="public", qop="auth", nonce="eaa1e15dd0e0d4e3760c8a82c799e2a2", opaque="7b5ca17f3c782ac1"
Content-Type: application/json; charset=utf-8
Content-Length: 104
Connection: Keep-Alive
Keep-Alive: timeout=5
{"errorResponse": {"statusCode":401,
"status":"Unauthorized",
"message":"401 Unauthorized"
}
}
PUT /v1/ext/test/evaltest.xqy HTTP/1.1
ML-Agent-ID: java
Authorization: Digest username="rest-admin", realm="public", nonce="eaa1e15dd0e0d4e3760c8a82c799e2a2", uri="/v1/ext/test/evaltest.xqy", response="18bad7d22af59c0e3ffe537014a71def", qop=auth, nc=00000001, cnonce="15af601b99993a21", algorithm=MD5, opaque="7b5ca17f3c782ac1"
Content-Type: text/plain
Transfer-Encoding: chunked
Host: 192.168.0.39:8012
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.6.0
0
HTTP/1.1 201 Created
Location:
Server: MarkLogic
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
Please note that, in order to make this work, we have a ping as a first call to get the nonce and then make this request. However if something goes awry and we encounter a situation like this, we should get a 401 and not retry which would result in an empty body.
rburgst commented
I wonder how I can find out whether a request is not repeatable
rburgst commented
can you please create a unit test that outlines this issue?
rburgst commented
closed due to inactivity