10 examples of 'xmlhttprequest set header' in JavaScript

Every line of 'xmlhttprequest set header' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
20function setHeader(xhr, headers) {
21 //"Content-Type":"application/x-www-form-urlencoded"
22 for(var iter in headers) {
23 xhr.setRequestHeader(iter, headers[iter]);
24 }
25}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

190setRequestHeader(header, value) {
191 const myHeader = _requestHeader.get(this)
192
193 myHeader[header] = value
194 _requestHeader.set(this, myHeader)
195}
308setRequestHeader(header: string, value: any): void {
309 if (this.readyState !== this.OPENED) {
310 throw new Error('Request has not been opened');
311 }
312 this._headers[header.toLowerCase()] = value;
313}
45setRequestHeader(key: string, value: any): void {
46 this.requestHeaders[key] = value;
47}
37function setRequestHeader(name, value) {
38 xhr.setRequestHeader(name, value);
39 headerLength += name.length + 2 + value.length + 1;
40}
25setHeader (name: string, value: string) {
26 // no-op
27}
14function set_request_header(key, value) {
15 xhr.setRequestHeader(key, value);
16}
252public setRequestHeader(header: string, value: string): void {
253 if (!this.headerObj) {
254 this.headerObj = {};
255 }
256 this.headerObj[header] = value;
257}
175public getResponseHeader(name: string): null | string {
176 if (this.readyState < MockXMLHttpRequest.HEADERS_RECEIVED) {
177 return null;
178 }
179
180 return this.res.headers[name.toLowerCase()];
181}
59configureXHR(xhr: XHR): void {
60 for (let name in this.headers) {
61 if (this.headers.hasOwnProperty(name)) {
62 xhr.setRequestHeader(this.headers[name].key, this.headers[name].value);
63 }
64 }
65}

Related snippets