http-headers

Response header not showing

我怕爱的太早我们不能终老 提交于 2020-01-29 20:37:13
问题 I am building a simple web app using ReactJS and create-react-app . I have a backend API set up on Heroku where I can make POST requests. Everything works fine, except: When I make a POST request using fetch API, the response is 100% correct but it only gives me 2 standard headers. I want to get my custom header. I have added expose header in my response and here's the plot twist: When I view the headers from Chrome Inspection Tool or Postman (API tool), it shows all the headers, including my

Use Content Security Policy scipt-src sha feature with Apache HTTP Server

≡放荡痞女 提交于 2020-01-25 20:17:21
问题 I'm using Apache 2.4 and I'm trying to implement Content Security Policy. I have set the following header in my httpd.conf Header set Content-Security-Policy "default 'none'; script-src 'self'" Now, I have inline javascript code using script tag inside html, as <script>alert('Do something here')</script> Note that script tag contains meaningful JS code, not this alert stuff I have put for sample purposes. Now, Content Security Policy blocks such inline scripts. One way to whitelist these is

How to validate header parameters with Sinatra?

旧时模样 提交于 2020-01-25 19:29:41
问题 I'm working on a simple API with Sinatra and I have a route like this one: get '/api/v1/invoice/:biller', :provides => [:json] do respond_with invoice( request ) end It works like a charm when I don't send any header params, but when I send: Accept Content-Type Then I got a 404 Not Found error and the classic Sinatra error 'Sinatra doesn't know this ditty' . How can I validate specific header params on Sinatra? Edit This is the actual header (Accept) with a curl example: curl -H "Accept:

How to validate header parameters with Sinatra?

大憨熊 提交于 2020-01-25 19:29:07
问题 I'm working on a simple API with Sinatra and I have a route like this one: get '/api/v1/invoice/:biller', :provides => [:json] do respond_with invoice( request ) end It works like a charm when I don't send any header params, but when I send: Accept Content-Type Then I got a 404 Not Found error and the classic Sinatra error 'Sinatra doesn't know this ditty' . How can I validate specific header params on Sinatra? Edit This is the actual header (Accept) with a curl example: curl -H "Accept:

Python SimpleHTTPServer: change response header

断了今生、忘了曾经 提交于 2020-01-25 11:11:11
问题 I use python's SimpleHTTPServer for tests applications. Now for the test I need to change in the server response header field "Server". Now I have "Server: SimpleHTTP/0.6 Python/2.7.3" I would like something like "Server: Apache123". Is it possible to change this field? Thx. 回答1: If you wanted to have something easy to edit you could use this: import SimpleHTTPServer import BaseHTTPServer def main(): request_handler = SimpleHTTPServer.SimpleHTTPRequestHandler request_handler.server_version =

CakePHP and FPDF: headers for view in browser

二次信任 提交于 2020-01-25 09:01:04
问题 I found many questions about which headers to use for download pdf files. Instead, I want to view them online (i.e. with the embedded Chrome plugin) and optionally download them with it. Here my code for CakePHP 3.7.9: pdf.ctp <?php header('Content-Type: application/pdf'); require_once(ROOT . DS . 'vendor' . DS . 'fpdf182' . DS . 'fpdf.php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); the related controller's function

Conditional Rendering on Server Side

不打扰是莪最后的温柔 提交于 2020-01-25 00:29:24
问题 Background I am using next.js for server side rendering and react.js for client side. Goal Want to do conditional rendering on the basis of window size in server side. Like for 200px width render A component and for 400px width render B component. Problem In server side, we have no access to the window object and we have no idea about the device our client is using. So AFAIK we cant do conditional rendering on server side. Thoughts I have thought of some solutions, but don't know is it

Conditional Rendering on Server Side

好久不见. 提交于 2020-01-25 00:29:03
问题 Background I am using next.js for server side rendering and react.js for client side. Goal Want to do conditional rendering on the basis of window size in server side. Like for 200px width render A component and for 400px width render B component. Problem In server side, we have no access to the window object and we have no idea about the device our client is using. So AFAIK we cant do conditional rendering on server side. Thoughts I have thought of some solutions, but don't know is it

PHP - How to check if request is for JS worker

雨燕双飞 提交于 2020-01-24 23:04:37
问题 After consulting MDN for the referrer-policy and Googling, DuckDucking and StackOverlow-searching, maybe you can help me with this rather simple (yet illusive) issue? Process Flow the browser makes a request to the server based on the HTTP_REFERER header, the server decides a response but why? (you ask) This is part of an elaborate set of security checks, in this case deciding if the client has access to a file requested FUBU (for us by us). This will not work if the referer is missing, but

Why is Firefox ignoring cache control on Range-based queries?

狂风中的少年 提交于 2020-01-24 09:02:13
问题 Web servers have the ability to stream media (audio in this example) to browsers. Browsers use HTML5 controls to play the media. What I'm discovering, however, is that Firefox is caching the media, even though I (believe I) explicitly tell it not to. I have a hunch that it has something to do with the 206 Partial Content response as a regular "non-range" GET with a full 200 OK response does not get cached. Chrome (27) handles this OK, but Firefox (21) does not: HTTP/1.1 206 Partial Content