Here is how the packets look
HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Thu, 18 Oct 2012 13:52:49 GMT
Server: LiteSpeed
Connection: close
X-Powered-By: PHP/5.3.10
Content-Type: text/html
Content-Length: 35
And
HTTP/1.1 200 OK
Content-Length: 35
Content-Type: text/html
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 18 Oct 2012 14:17:13 GMT
Connection: close
The GZIP output for both is the same yet the top one which is generated with PHP works and the bottom one which is HttpListenerResponse generated doesn't with a POST request, even though you can view both in a browser. I also do not call cross domain/port.
How do I make the second request work?
Added some headers removed some headers everything started working! You need to allow access control origin or it will only work on IE.
Related
GoogleDrive update API returns a 500 error.
This error occurs when calling with the title in the request body.
We are sending a request as follows:
PUT https://www.googleapis.com/drive/v2/files/{fileId}
Authorization: Bearer {Authorization}
Content-Type: multipart/related; boundary=25266828
Host: www.googleapis.com
Content-Length: 140
--25266828
Content-Type: application/json; charset=UTF-8
{"title":"renamed_name.jpg"}
--25266828--
The message included the following wording.
[Internal Server Error] [Unknown Error]
We first detected this issue on June 14th.
Previously it worked fine and I haven't changed the source code.
Has there been any change?
here is a very simply MVC asynchronous action:
[HttpPost]
public async Task<ContentResult> Trial()
{
ContentResult contentResult = await new Task<ContentResult>(()=>new ContentResult{Content="Hi"});
return contentResult;
}
I would expect a post to this action to respond with the content "Hi". But it does not. It responds with the content "System.Threading.Tasks.Task`1[System.Web.Mvc.ContentResult]".
Here is the full response:
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: -1
Vary: Accept-Encoding
X-UA-Compatible: IE=Edge
Date: Mon, 23 Nov 2020 17:02:37 GMT
Content-Length: 166
System.Threading.Tasks.Task`1[System.Web.Mvc.ContentResult]
Would love some insights into why, and how to get the content "Hi" as expected, using an Async function. Thanks.
This can happen if you're using a very old version of MVC. You must be running (at least) ASP.NET 4.5 on .NET Framework 4.5 for Task-returning action method to work. Microsoft.Bcl.Async does not work for ASP.NET projects.
If you have .NET Framework 4.5 or newer on your web servers, you can upgrade your project to ASP.NET 4.5. After upgrading, you must turn off "quirks mode" for async to work properly. I prefer to do this by setting httpRuntime.targetFramework in your web.config to 4.5 (or whatever version you upgrade to).
I'm using Abot (C#) to crawl a website using the standard settings in their getting started documentation.
After retrieving a web page I can't read the content - it doesn't appear to have been decoded correctly.
If I comment out the Abot code and just use the standard (HttpWebResponse)request.GetResponse() .net method I can see the page content correctly.
I want to use Abot for its scraping capabilities though. But as you can see below I get a load of incorrectly decoded content.
Has anyone got any ideas on how I can fix the problem?
EDIT: I'm pretty sure its something to do with the website as I don't have the same problem if I run against http://www.google.com
EDIT 2: Here are the headers
WebRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko
Accept: */*
Host: www.<website>.com
Connection: Keep-Alive
WebResponse
Transfer-Encoding: chunked
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Date: Wed, 29 Jul 2015 12:28:53 GMT
Set-Cookie: __cfduid=de5028c9ea76b127d7aebe40617a7a6b51438172932; expires=Thu, 28-Jul-16 12:28:52 GMT; path=/; domain=.<website>.com; HttpOnly,PHPSESSID=e2ekece8flgs000h6u6kvf66k6; path=/,ct_cookies_test=7a1a1460017221ec70f96f0f2a3cdaac; path=/
X-Powered-By: W3 Total Cache/0.9.4.1
Expires: Wed, 29 Jul 2015 13:28:53 GMT
Cache-Control: max-age=3600, public, must-revalidate, proxy-revalidate
Pragma: public
X-Pingback: http://www.<website>.com/<file>.php
Link: <http://wp.me/P2xmvI-a>; rel=shortlink
Last-Modified: Wed, 29 Jul 2015 12:28:53 GMT
Vary: Accept-Encoding,User-Agent
Server: cloudflare-nginx
CF-RAY: 20d8d37b9fc406be-LHR
If you remove the User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko header your response will probably be more readable. I'm not sure but it looks like the web server encodes responses sent to this user agent in some way. (I'm not an expert either)
I can recommend you to use Fiddler (http://www.telerik.com/fiddler) to check how web requests are handled. (Which is quite nice for debugging this kind of problems)
Bad content seen in fiddler
Correct content seen in fiddler
I'm responsible for updating a client-side API using WCF. This is because of changes to the API on the server (an outside company). When I get the response, my client-side throws an exception. Using Fiddler, I came up with the following problem: a duplicate Content-Type.
HTTP/1.1 200 OK
Date: Thu, 05 Jan 2012 21:15:16 GMT
Connection: close
Content-Type: text/xml; charset=utf-8
Content-Type: text/xml; charset=UTF-8
Content-Length: 538
...
Using Fiddler, I removed the extra Content-Type, and the client continued happily. So, I wrote an IClientMessageInspector, with the intention of capturing the response and removing the duplicate. And therein lies my issue. My IClientMessageInspector gets a call to BeforeSendRequest, but not one to AfterReceiveRequest.
Is there some place other than AfterReceiveRequest that I should be handling my task of removing the extra Content-Type? Am I barking up the wrong tree altogether?
An external development partner has a service that will post a SOAP request to one of our services. The format of their request is fixed (by them).
We are required to respond with a SOAP message of a fixed format (fixed by them again).
I have created a Generic Handler in ASP.Net that successfully receives their request (which we parse manually and process).
However, they want a response that looks like this:
HTTP/1.1 200 OK
Date: Thu, 01 Apr 2010 09:30:25 GMT
Server: Jetty/5.1.4 (Windows XP/5.1 x86 java/1.5.0_15
Content-Type: multipart/related; boundary=soaptestserver; type="text/xml"; start="<theenvelope>"
SOAPAction: ""
Content-Length: 796
Connection: close
--soaptestserver
Content-ID: <theenvelope>
Content-Transfer-Encoding: 8bit
Content-Type: text/xml; charset=utf-8
Content-Length: 442
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAPENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><SOAPENV:
Body><ns1:processResponse xmlns:ns1="urn:TripFlow" SOAPENV:
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><message
href="cid:thecontentmessage"/></ns1:processResponse></SOAP-ENV:Body></SOAPENV:
Envelope>
--soaptestserver
Content-ID: <thecontentmessage>
Content-Transfer-Encoding: 8bit
Content-Type: text/xml; charset=utf-8
Content-Length: 65
<?xml version="1.0" encoding="UTF-8"?><STATUSLVL>00</STATUSLVL>
--soaptestserver--
I have been so sheltered from raw SOAP by using .Net Webservices / WCF for years, that I have no clue about how to go about making a response like this.
What should I do?