http-headers

how do I set a custom header in a curl config file

我是研究僧i 提交于 2019-12-19 21:51:20
问题 How do I add the option for setting a custom header in a curl config file? Neither of the following lines did work: Header = 'x-abc: xyz' header = 'x-abc: xyz' 回答1: -H:"x-abc: xyz" works fine: curl -vvv -K headerfile http://www.google.com -o /dev/null * About to connect() to www.google.com port 80 (#0) * Trying 74.125.230.243... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* connected *

Receive the HTTP status after a request with Spring MVC

社会主义新天地 提交于 2019-12-19 20:23:12
问题 i'm sending data to a server and i want to receive the HTTP response status in order to check this status and provide the appropriate view @RequestMapping(method = RequestMethod.POST) public String Login(@ModelAttribute("Attribute") Login login, Model model,HttpServletRequest request) { // Prepare acceptable media type ArrayList<MediaType> acceptableMediaTypes = new ArrayList<MediaType>(); acceptableMediaTypes.add(MediaType.APPLICATION_XML); // Prepare header HttpHeaders headers = new

Set Title of Inline File?

不羁的心 提交于 2019-12-19 19:40:28
问题 I'm forcing a download to be handled by the browser by setting the header Content-disposition to inline; Is there a way of setting the title this way? Currently it looks like the browser auto-fills it with the URL of the file. 回答1: Yes, you can specify the filename just like you'd do for content-disposition: attachment , i.e. like this: Content-disposition: inline; filename="foo.bar" See this post for some useful information about this header: How to encode the filename parameter of Content

Load desktop version WKWebView iOS 9

牧云@^-^@ 提交于 2019-12-19 11:45:06
问题 Up until recently let url = NSURL (string:http://asite.com) let request = NSMutableURLRequest(URL: url!) //iOS loads the mobile version of asite.com which does not have the required DOM so we force the desktop version by setting new value forHTTPHeadrField let newUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.6 Safari/537.11" request.setValue(newUserAgent, forHTTPHeaderField: "User_Agent") let config = WKWebViewConfiguration

Clear cache on back press to prevent going back on login page or previous page after logout

最后都变了- 提交于 2019-12-19 11:26:08
问题 this is bugging me for a week already. Well I just badly needed to clear the cache of the login page after the user successfully logged in and prevent user from viewing the previous page after logging out when the back button is pressed. I tried adding this codes up in my work (both index page and the login page) in codeigniter but still nothing happens header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Pragma: no-cache"); as well as

PHP get_headers not working?

倖福魔咒の 提交于 2019-12-19 10:52:34
问题 I want to get headers of website but get_headers return nothing This is my code <?php $url = 'http://www.example.com'; print_r(get_headers($url)); ?> For your information my web hosting provider is network solution Does the problem from my code or from the web hosting provider ? And what's the solution to get the headers of one website ? 回答1: If get_headers is disabled then you can also use cURL instead. $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_HEADER

Basic authentication using XHR

喜夏-厌秋 提交于 2019-12-19 10:16:31
问题 I am trying to get some response from my server which needs basic authentication. So when I use curl as: curl -u user:pass http://myserver.com/get/send-my-data It is giving me correct response. But when I am creating an XHR request using jquery AJAX. I am having 403 error. Here is my AJAX setup: $.ajax ({ type: 'GET', url: 'http://myserver.com/get/send-my-data', beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Basic" + encode64(user:pass)); // I have calculated base64

Getting '400 Bad Request' when using multipart/form-data as Content-Type in XHR

做~自己de王妃 提交于 2019-12-19 09:45:20
问题 I have an AJAX request that sends out some data. The data respects the multipart/form-data specification. The problem I'm facing is that the browser sets the Content-Type header to text/plain and it should be multipart/form-data. I've tried doing this: request.setRequestHeader("Content-Type", "multipart/form-data"); but this gives out an 400 Bad Request error. If I do request.setRequestHeader("Content-Typexxxx", "multipart/form-data"); there is no error, the "Content-Typexxxx" header is set

ServerXMLHTTP appending to content-type

江枫思渺然 提交于 2019-12-19 09:23:13
问题 I am making a server-side HTTP request with a JSON body in VBScript like this: Set oXMLHttp = Server.CreateObject("MSXML2.ServerXMLHTTP") oXMLHttp.open cMethod, cAPIURL, False, cUser, cPassword oXMLHttp.setRequestHeader "Content-Type", "application/json" oXMLHttp.send(cData) cReturn = oXMLHttp.responseText Set oXMLHttp = Nothing The service I'm calling expects the content-type to be application/json , naturally. As you can see, I'm setting the request header above to be as such. The issue is

How can I perform a HEAD request with the mechanize library?

孤者浪人 提交于 2019-12-19 09:19:34
问题 I know how to do a HEAD request with httplib, but I have to use mechanize for this site. Essentially, what I need to do is grab a value from the header (filename) without actually downloading the file. Any suggestions how I could accomplish this? 回答1: Mechanize itself only sends GETs and POSTs, but you can easily extend the Request class to send HEAD. Example: import mechanize class HeadRequest(mechanize.Request): def get_method(self): return "HEAD" request = HeadRequest("http://www.example