HTTP PUT无法正常工作

时间:2011-12-30 15:50:07

标签: c# http powershell

我正在尝试使用此函数发送字符串。

function submit_report_http
{
    param($report)
    trap{return 1}
    if($verbose -gt 1){minfo 'Sending report via http, url is ' + $http_url}
    $webRequest = [System.Net.WebRequest]::Create($http_url)
    $webRequest.ContentType = "text/html"
    $PostStr = [System.Text.Encoding]::UTF8.GetBytes($report)
    $webrequest.ContentLength = $PostStr.Length
    $webRequest.ServicePoint.Expect100Continue = $false
    if($verbose -gt 1){minfo ' authenticating user: ' + $http_user}
    $webRequest.Credentials = New-Object System.Net.NetworkCredential -ArgumentList $http_user, $http_pass
    $webRequest.PreAuthenticate = $true
    $webRequest.Method = "PUT"
    $requestStream = $webRequest.GetRequestStream()
    $requestStream.Write($PostStr, 0,$PostStr.length)
    $requestStream.Flush()
    $requestStream.Close()
}

当我到达这条线时:

$requestStream = $webrequest.GetRequestStream()

脚本似乎进入无限循环。

有人能看到问题吗?

吉斯利

1 个答案:

答案 0 :(得分:1)

我建议使用WireShark查看线路上发生的情况,并检查服务器日志。