简体   繁体   English

在Java中放心的https请求

[英]https request with rest assured in java

I have a .pdf file on s3 and i want to check the status of this .pdf via hitting s3 url like https://s3.xyz?hello/abc.pdf I have written code like:- Assert.assertEquals(given().request("CONNECT",jp.getString("rurl")).statusCode(),200, " Status of rurl is not 200:- " +jp.getString("rurl")) 我在s3上有一个.pdf文件,我想通过点击s3网址(例如https://s3.xyz?hello/abc.pdf)检查此.pdf的状态,我编写了类似以下代码:-Assert.assertEquals(given( ).request(“ CONNECT”,jp.getString(“ rurl”))。statusCode(),200,“ rurl的状态不是200:-” + jp.getString(“ rurl”))

where rurl like https://s3.xyz?hello/abc.pdf this code prints status as 403 but when i checked this api it returns 200 and because of this assertion my test case fails every time. https://s3.xyz?hello/abc.pdf这样的网址,此代码将状态显示为403,但是当我检查此api时,它返回200,并且由于此断言,我的测试用例每次都失败。 please revert, mi doing something wrong. 请还原,我做错了什么。 How to check apis with https protocol. 如何使用https协议检查api。

I guess you are facing Cross Origin Resource Sharing(CORS) issue. 我猜您正在面临跨源资源共享(CORS)问题。 Depending on the framework/server you are using this can be fixed by adding necessary HTTP headers. 根据所使用的框架/服务器,可以通过添加必要的HTTP标头来解决此问题。

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM