I have a API which sends response having following header:
Headers(8)
Test Results(1/1)
Status:200 OK
Time:5890 ms
Size:1.24 MB
Access-Control-Allow-Origin →*
Cache-Control →no-cache
Content-Disposition →attachment; filename=Report.csv
Content-Length →1298149
Content-Type →text/csv
Date →Fri, 22 Jun 2018 08:50:05 GMT
Expires →-1
Pragma →no-cache
I want to download the attachment file 'Report.Csv'
Can anyone suggest How can I do it via script or newman
If you're sending a request from within the Postman app, you can "Send and download" the response.
...you should select “Send and download”
which will let you save the response to your hard disk.
If you're trying to do it by script, here's a tutorial about writing to your local file system by running a local server, or how to use Newman to do something similar.
Related
Is there any way to remove the response header location when making a post via HTTP connector in the logic app or via a postman?
Response Headers
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Location: http://xxxx.xxx/api/integrationstatus?id=xxxxx
Date: Thu, 11 Mar 2021 10:13:53 GMT
If you mean remove the Location field from response header just inside the HTTP connector, I'm afraid the answer is "no". And to remove it inside postman, the answer is also "no".
But if your requirement is to get the data of response header, at that time remove the location field. This can be implemented, here provide two solutions for your reference.
1. We can do it by "Execute Javascript Code" action in your logic app. Before use "Execute Javascript Code" action, you need to create integration account and link it to your logic app. Then use the js code like below screenshot:
2. If you do not want to create integration account to use "Execute Javascript Code" action. You can also do it by "Compose" action. List all of other fields in "Compose" by their expression. For example, the expression for Cache-Control is outputs('HTTP')['headers']?['Cache-Control'].
My understanding of setting Cache-Control with a max-age value is that the browser is instructed to Cache the file.
What I then expect is that if I hit "enter" on the address bar for the same link, the browser would return a 200 (from cache) response.
My question is that why is it returning a 304 Not Modified response?
The way I see it is that with the 200 (from cache) the browser no longer makes a connection with the Server to validate the file and immediately just serves the cached content. But with the 304, although the browser will not download the file again and will simply instruct the browser to serve the cached file, it will still need to send a request to validate the freshness of the content.
The assets here are served with Amazon's CloudFront CDN with Amazon S3 buckets as the origin. The Cache-Header there (in S3) have been set already. This was is not an issue for all other self-hosted assets.
Thanks for the help!
EDIT: I found this What is the difference between HTTP status code 200 (cache) vs status code 304?. Additional question: I already have Cache-Control set to max-age=31536000, s-maxage=2592000, no-transform, public and still I'm getting a 304, do it need to set the Expire also? I could cache fine before on self-hosted sites with just the Cache-Control.
You expect to see a 200 with the content, rather than a 304 saying "not modified". That's the browser asking to see if the content is newer than what it has cached. 304 means "no, don't waste your bandwidth, your content is current". It can do this with a couple of methods- etag and if-modified-since.
As an example, we can use your stackoverflow avatar image. When I load that in Chrome and look at the Developer Tools, I can see it has a 304 response and is passing those two headers:
if-modified-since:Thu, 28 Jan 2016 13:16:24 GMT
if-none-match:"484ab25da1294b24f8d9d13afb913afd"
I'm experiencing problem with HLS from Akamai.
I'm using HLS from Akamai with tokens, in order to start stream, Cookies should be set after master m3u8 playlist response.
Response from Akamai:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Content-Type
Cache-Control:max-age=0, no-cache, no-store
Connection:keep-alive
Content-Length:818
Content-Type:application/vnd.apple.mpegurl
Date:Wed, 17 Sep 2014 12:15:54 GMT
Expires:Wed, 17 Sep 2014 12:15:54 GMT
Mime-Version:1.0
Pragma:no-cache
Server:AkamaiGHost
Set-Cookie:_alid_=/cropped/
Set-Cookie:hdntl=/cropped/
I'm rewriting Host.updateManifestRequestInfo in both scenarios there is a dead end.
If you use requestInfo.withCredentials = true;, response will be:
XMLHttpRequest cannot load /*MEDIA_URL*/. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin '/*PLAYERS_HOST*/' is therefore not allowed access.
With requestInfo.withCredentials = false; will be 403 response.
What is correct way in implementation of Custom Player for HLS from Akamai with tokens?
I know it is a very old post, but in case somebody gets the same problem in the future: If you set withCredentials to true, then the Akamai response has to explicitly authorise your ChromeCast receiver through their CORS header.
Please ask Akamai to add the domain of your receiver to their CORS and the issue will be resolved. Please have a look at this page for more info: https://developers.google.com/cast/docs/player.
You need to write a custom receiver (using MPL) and use host to override updateManifestRequestInfo / updateSegmentRequestInfo to achieve the desired behavior.
I have a scenario in which a client application sends a POST request to an asp.net page to which the page responds with a json string which I need to consume on the client side.
However, Internet explorer is trying to download the *.aspx page, containing the json string.
What HTTP headers must the response contain to disable the download in Internet Explorer?
Currently, the response HTTP headers are:
Access-Control-Allow-Headers:X-File-Name,X-File-Type,X-File-Size
Access-Control-Allow-Methods:GET,POST,OPTIONS
Access-Control-Allow-Origin:*
Cache-Control:private,private, no-cache
Content-Length:1050
Content-Type:application/json; charset=utf-8
Date:Fri, 12 Jul 2013 08:24:24 GMT
Pragma:no-cache
Server:Microsoft-IIS/7.5
Set-Cookie:ASP.NET_SessionId=qjudp3nct3czltyvc4yxpiri; path=/; HttpOnly
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
It depends on how you are consuming that web service.
If you are consuming it from inside a web page using jQuery, it shouldn't be a problem, Internet Explorer won't force download the file.
If you access the file directly after the POST (redirect to the URL that serves the JSON) and you want to display the JSON as plain text, you must set the Content-Type to text/plain; charset=utf-8
I need to set a cookie before I issue a request to a Web site using Fiddler. How do I do this?
Simple...You need to set a header value, with your request, like so:
Cookie: YourCookieName=YourCookieValue
To do this using the FiddlerScript engine, add the following code into the onBeforeRequest method:
oSession.oRequest["Cookie"] = (oSession.oRequest["Cookie"] + ";YourCookieName=YourCookieValue");
This will preserve any other cookies that have been set.
You need to be more specific about what you're trying to do.
You can edit (or add) an outbound Cookie header to send a cookie to the website. You can do this either manually or via the FiddlerScript engine. But that doesn't "set" the cookie on the client-- it simply sends it to the server. If you want to set a cookie on the client, you either have to use another means, or you can inject a Set-Cookie response header on a previous response from the server, with the value you want to set on the client.
You can also use the Fiddler Composer.
Run Fiddler
Open the Composer Tab on the top.
It's easiest if you can start with another request from your web site. To do this capture a the request you want to modify, then drag it from the UI to the composer tab.
A good explanation is here: http://www.debugtheweb.com/Fiddler/help/composer.asp
Fiddler allows your to resend/rebuild an existing request. There is a Request Builder. While rebuilding in the RAW form, modify your cookies.
This solution is valid for Cookie based authentication:
If you want to test the API/url which have authentication enabled, please try following, i am showing for MVC web API on IIS server. usually there are more than 1 cookie responsible for authorization, so you may need to send more than 1 cookie in header as follows:
User-Agent: Fiddler Host: localhost:51000 content-Type: application/json Cookie : .ASPXAUTH=xxxxx;ASP.NET_SessionId=yyyy;__RequestVerificationToken=zzzz
When running Fiddler as a reverse Proxy you can modify the response headers
via FiddlerScript by adding a line in the OnBeforeResponse method:
static function OnBeforeResponse(oSession: Session) {
// ...
oSession.oResponse["Set-Cookie"] = "sessionToken=abc123; Expires=Wed, 09 Jun 2021 10:18:14 GMT";
}
Also check Fiddler docs about Modifying a Request or Response for more info.