Skip to content

Commit

Permalink
Fixed compilation errors with request headers which can contain 'stri…
Browse files Browse the repository at this point in the history
…ng[]'
  • Loading branch information
AdrienCastex committed Dec 26, 2017
1 parent 3f26a18 commit 1fcbbe2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/server/MethodCallArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var MethodCallArgs = (function () {
name = name.replace(/(-| )/g, '').toLowerCase();
for (var k in this.request.headers)
if (k.replace(/(-| )/g, '').toLowerCase() === name)
return this.request.headers[k];
return this.request.headers[k].toString();
return defaultValue;
};
MethodCallArgs.prototype.getResource = function (callback) {
Expand Down
6 changes: 3 additions & 3 deletions lib/server/v2/RequestContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { IUser } from '../../user/v2/IUser';
import * as http from 'http';
export declare class RequestContextHeaders {
protected headers: {
[name: string]: string;
[name: string]: string | string[];
};
contentLength: number;
isSource: boolean;
depth: number;
host: string;
constructor(headers: {
[name: string]: string;
[name: string]: string | string[];
});
find(name: string, defaultValue?: string): string;
findBestAccept(defaultType?: string): string;
Expand Down Expand Up @@ -48,7 +48,7 @@ export declare class RequestContext {
server: WebDAVServer;
user: IUser;
protected constructor(server: WebDAVServer, uri: string, headers: {
[name: string]: string;
[name: string]: string | string[];
}, rootPath?: string);
getResource(callback: ReturnCallback<Resource>): void;
getResource(path: Path | string, callback: ReturnCallback<Resource>): void;
Expand Down
2 changes: 1 addition & 1 deletion lib/server/v2/RequestContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var RequestContextHeaders = (function () {
name = name.replace(/(-| )/g, '').toLowerCase();
for (var k in this.headers)
if (k.replace(/(-| )/g, '').toLowerCase() === name) {
var value = this.headers[k].trim();
var value = this.headers[k].toString().trim();
if (value.length !== 0)
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/MethodCallArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class MethodCallArgs

for(const k in this.request.headers)
if(k.replace(/(-| )/g, '').toLowerCase() === name)
return this.request.headers[k];
return this.request.headers[k].toString();

return defaultValue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/v2/RequestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class RequestContextHeaders
depth : number
host : string

constructor(protected headers : { [name : string] : string })
constructor(protected headers : { [name : string] : string | string[] })
{
this.isSource = this.find('source', 'F').toUpperCase() === 'T' || this.find('translate', 'T').toUpperCase() === 'F';
this.host = this.find('Host', 'localhost');
Expand Down Expand Up @@ -53,7 +53,7 @@ export class RequestContextHeaders
for(const k in this.headers)
if(k.replace(/(-| )/g, '').toLowerCase() === name)
{
const value = this.headers[k].trim();
const value = this.headers[k].toString().trim();
if(value.length !== 0)
return value;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ export class RequestContext
server : WebDAVServer
user : IUser

protected constructor(server : WebDAVServer, uri : string, headers : { [name : string] : string }, rootPath ?: string)
protected constructor(server : WebDAVServer, uri : string, headers : { [name : string] : string | string[] }, rootPath ?: string)
{
this.overridePrivileges = false;
this.rootPath = rootPath;
Expand Down

0 comments on commit 1fcbbe2

Please sign in to comment.