我有正在作出POST到服務器的工作MacOS的應用程序。我更改了POST的URL並停止工作。ASIFormDataRequest具有空POST體
我下載Tuffcode(嗅探器),這表明我使用新的URL時,POST正文是空的!
- (IBAction)grabURLInBackground:(id)sender
{
NSURL *url = [NSURL URLWithString:@"url1"];
//NSURL *url = [NSURL URLWithString:@"url2"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request addRequestHeader:@"Content-Language" value:@"en"];
[request addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"];
[request addRequestHeader:@"Connection" value:@"keep-alive"];
[request addRequestHeader:@"Cookie" value: [NSString stringWithFormat:@"botcust2=%@", sn]];
[request setShouldAttemptPersistentConnection:NO];
[request addPostValue:[input stringValue] forKey:@"input"];
[input setStringValue:@""];
[request startAsynchronous];
}
從url1切換到url2從良好的POST BODY轉到空的POST BODY。那怎麼可能? URL如何確定發送的內容? 起初我以爲是不正確解釋發佈新的服務器,但如果Tuffcode是正確的,應用程序甚至不發送數據?
或者,也許有一些我不知道如何HTTP的工作原理?我很困惑...
一些日誌:
2011-07-29 12:28:36.018 ChatBot[6764:707] [STATUS] Starting asynchronous request <ASIFormDataRequest: 0x10188d420>
2011-07-29 12:28:36.021 ChatBot[6764:6403]
==== Building an application/x-www-form-urlencoded body ====
input=hello
==== End of application/x-www-form-urlencoded body ====
2011-07-29 12:28:36.027 ChatBot[6764:6403] [CONNECTION] Request <ASIFormDataRequest: 0x10188d420> will not use a persistent connection
2011-07-29 12:28:36.280 ChatBot[6764:6403] [STATUS] Request <ASIFormDataRequest: 0x10188d420> finished uploading data
2011-07-29 12:28:36.374 ChatBot[6764:6403] [STATUS] Request <ASIFormDataRequest: 0x10188d420> received response headers
2011-07-29 12:28:36.375 ChatBot[6764:6403] [STATUS] Request <ASIFormDataRequest: 0x10188d420> finished downloading data (0 bytes)
2011-07-29 12:28:36.376 ChatBot[6764:6403] [STATUS] Request finished: <ASIFormDataRequest: 0x10188d420>
也要注意,使用HTML表單在瀏覽器中運行,這兩個URL工作罰款 –