2014-09-29 7 views
-1

나는이 서버 측 ASP 스크립트에서 작업 중입니다. 웹 응용 프로그램에서 XML 스트림을 받아 xml 파일로 저장해야합니다. 문제는이 스트림을 읽을 수 없다는 것입니다. 나는 다른 방법을 사용했는데 나는 맞는 방법을 찾을 수없는 것 같습니다. 한가지 다른 것은 크롬 용 나머지 콘솔 추가 기능을 사용하고있는 테스트 용이며 아무런 문제없이 작동하는 것 같습니다. 클라이언트가 스트림을 보내면 읽을 수없고 코드 500 오류가 발생합니다.httprequest에서 데이터 가져 오기

처음에 나는 바이너리 모드 스트림은 다음을

function readContent() 
    dim a,b 
    a=Request.TotalBytes 
    b=Request.BinaryRead(a) 
    writeInLogFile(" ") 
    writeInLogFile(Time & Request.ServerVariables("ALL_RAW")) 
    writeInLogFile(Time & " Data read in binary mode with a size of " & a) 
    readContent = URLDecode(BytesToStr(b)) 
    writeInLogFile(Time & " the length of the converted string is : "& len(readContent)) 
end function 

변환하지만 여기 내 로그 파일

17:12:10Content-Length: 8416 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
Authorization: Basic 
Host: 
User-Agent: Jakarta Commons-HttpClient/2.0.2 

17:12:10 Data read in binary mode with a size of 8416 

17:12:10 Converting binary to string

을에 점점 계속 무엇 내가 쓰려고하면 다음 충돌 읽기 시도 변환 된 문자열 다음

나는

function readContent() 
    'writeInLogFile(Time & " " & URLDecode(Request.Form)) 
    writeInLogFile(Time & Request.ServerVariables("ALL_RAW")) 
    readContent = URLDecode(Request.Form) 
    writeInLogFile(Time & " the length of the converted string is : "& len(readContent)) 
end function 
을으로 Request.Form로 전환

하지만 아직 다시 콘솔을 통한 테스트가 모두 작동하고 실제로 클라이언트에서 스트림을 수신하면 충돌이 발생합니다.

사람은 비슷한 문제에 직면하거나, 내가이 일을 사전에

감사를 해결할 수있는 방법에 대한 아이디어가

업데이트 : 여기

가 디코딩 기능

FUNCTION URLDecode(str) 
    '// This function: 
    '// - decodes any utf-8 encoded characters into unicode characters eg. (%C3%A5 = å) 
    '// - replaces any plus sign separators with a space character 
    '// 
    '// IMPORTANT: 
    '// Your webpage must use the UTF-8 character set. Easiest method is to use this META tag: 
    '// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    '// 
    Dim objScript 
    Set objScript = Server.CreateObject("ScriptControl") 
    objScript.Language = "JavaScript" 
    URLDecode = objScript.Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))") 
    Set objScript = NOTHING 
    'writeInLogFile(Time & " the length of the converted string is : "& len(URLDecode)) 
END FUNCTION 
+0

관련 코드가 누락되었습니다.이 두 함수의 소스는 어떻게 생겼습니까? 'URLDecode (BytesToStr (b))'. 하지만 당신이하려고하는 것을보고 나는 문제가'URLDecode()'함수에 있다고 말하고 싶습니다. – Lankymart

+0

아니요 로컬에서 테스트 할 때 (나머지 콘솔) 모든 것이 원활하게 실행되고 함수가 완벽하게 작동하는 것처럼 URLDecode() 함수에 오류가 없습니다. – bibo

+0

아무 문제가 없다고 생각하면 분명히 무엇을하는지 알 것입니다. 행운을 빕니다. – Lankymart

답변

0

에게 있습니다 클라이언트가 보낸 인코딩은 실제로 스트림에서 보낸 인코딩과 다릅니다.

Request.Form이 답입니다.