does the restify client http post callback function have the limitation of the character length? - restify

when i call client http post in restify like this:
client.post( '/hdapi/User/sendSms',jssendSms, function(hdregistererr,hdregisterreq,hdregisterres,hdregisterobj)
it failed and print the error info:
AssertionError [ERR_ASSERTION]: callback (func) is required
at HttpClient.request (/root/node_modules/restify-clients/lib/HttpClient.js:716:12)
at HttpClient.post (/root/node_modules/restify-clients/lib/HttpClient.js:667:18)
at why (/root/myapp/app.js:354:17)
when i changed those codes to
client.post( '/hdapi/User/sendSms',jssendSms,
function(hdregerr,hdregreq,hdregres,hdregobj) {
it passed, so does the restify client http post callback function have the limitation of the character length ?

Related

PATCH operation failing in Karate Version 1.2.0. It return HTTP call failed

I am trying to perform patch operation using latest version of Karate with below,
Also I notice the special charater "/" in the payload is replaced by "/" in the report. Hoping that is not a issue as I tried sending the exact payload captured in report through postman and the request went through. Is there a way to avoid replacing that special characters, even after using charset UTF-8 and surefire plugin configuration?
Scenario: Test for PATCH METHOD
Given url URL
And request [{ "op":"replace","path":"/Package/Content/Application/OtherIncome/0/#Frequency","value":"Monthly"}]
And header Content-Type = 'application/json-patch+json; charset=utf-8'
And header Accept = 'application/json'
When method patch
Then status 200
Error:
00:19:07.042 java.lang.RuntimeException: java.io.EOFException, http call failed after 2575 milliseconds for url: https://apigateway.bbldtl.int/babl/int/dev/loan-application-api/v1/applications/22634247
00:19:07.042 classpath:loanApplicationApi/Patch/editIncome/editIncome.feature:15
When method patch
http call failed after 2575 milliseconds for url: https://apigateway.bbldtl.int/babl/int/dev/loan-application-api/v1/applications/22634247
classpath:loanApplicationApi/Patch/editIncome/editIncome.feature:15

Request in Postman with same cookies and headers like in browser returns 401, but in browser all works fine

I trying to scraping data from this url:
https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11
In web browser, if I visit main page https://rgis.mosreg.ru first (to get cookies), and next - go to this url - all works fine.
But when I trying to perform this request in Postman - its fault with 401 "Unautorized" error.
In Postman I use all same headers and cookies, like in web-browser, but it does not help.
All cookies and headers are synced with browser using Postman INTERCEPTOR
What I missing out?
Chrome screen with headers
Postman screen. Header "mojo" looks line auth header
The server seems to only accept HTTP/2 and reject HTTP/1.1 call. If you have curl compiled with http2 support, you can test this directly:
curl --http2 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
Output
< HTTP/2.0 200
< server:nginx/1.19.5 (MOGT Edition # rgis-pub-app-01)
otherwise it returns 401
At the moment, you can't run this request in Postman, because Postman doesn't have http2 support yet
You can also test it with python using the httpx package (pip install httpx[http2]):
import httpx
import asyncio
url = 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
r = httpx.get(url)
print(r.http_version)
print(r.status_code)
client = httpx.AsyncClient(http2=True)
async def get():
response = await client.get(url)
print(response.http_version)
print(response.status_code)
asyncio.run(get())
Output
HTTP/1.1
401
HTTP/2
200

Spring Cloud Gateway hides server websocket handshake 401 failures to clients

I'm reverse proxying a websocket backend API with spring-cloud-gateway 2.2.3. When this backend API rejects some websocket handshake request with a 401 Unauthorized status response, then spring-cloud-gateway still returns a 101 handshake status to the client (which gets confused and then misbehaves)
I need spring-cloud-gateway to return the original 401 websocket handshake error to the client so the SCG reverse proxy is transparent to the client (which is conforming to the WebSocket specs handshake)
Here are the full wiretap traces and exception (I have redacted hostnames).
The client-side response in this WSS request is available as a HAR file captured from chrome and which displays in chrome
as this screenpshot.
Here is my spring cloud gateway configuration
spring:
cloud:
gateway:
routes:
- id: route_shield
uri: https://shield-webui-cf-mysql.nd-int-cfapi.was.redacted
predicates:
- Host=**
filters:
- SetRequestHostHeader=shield-webui-cf-mysql.nd-int-cfapi.was.redacted
ssl:
useInsecureTrustManager: true
I'm wondering whether this is a spring-cloud-gateway bug, or a desired behavior which I can override.
To override it, here are alternatives I'm considering:
using circuit breaker filter and fallback to a local handler returning a 401
write a custom post-filter
Override/patch the WebsocketRoutingFilter
However my debugger breakpoint in the handle(WebSocketSession session) method does not trigger, suspecting it is not called
Likely would need to provide a RequestUpgradeStrategy bean as an alternative to the default implementation of org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy#getNativeResponse mentionned in the trace
io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 401 Unauthorized
at io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13.verify(WebSocketClientHandshaker13.java:274) ~[netty-codec-http-4.1.51.Final.jar:4.1.51.Final]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ http://localhost:8080/v2/events [ReactorNettyRequestUpgradeStrategy]

Karate returns HTTP 415 for soap request

I'm trying to hit a SOAP service using karate and it always returns 415, whereas the same service is successful in SOAP UI.
Response in Karate:
20:05:37 20:05:37.236 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 37.15
20:05:37 1 < 415
20:05:37 1 < Content-Length: 0
Given url soapServiceURL
And header Content-Type = 'application/xml'
And request requestPayLoad
When method post
Then status 200
Kindly advise if I'm missing something here
Please read the docs and use soap action if needed: https://github.com/intuit/karate#soap-action
Karate can make any HTTP request, but you need to figure out the right headers etc. One hint is export to cURL and then you will be able to do it easily.

How to pass API gateway context variable to proxy lambda

I am looking for guidance on how to pass the API Gateway context variable (for example: $context.RequestTime) to the proxy lamba.
Basically I want to send the time request has reached in Api gateway to my lambda proxy method as a request header.
Note that I am using serverless framework (serverless.com)
I tried the following but it does not work
events:
- http:
path: /{proxy+}
method: ANY
request:
parameters:
paths:
proxy: true
headers:
requestTime: $context.requestTime