Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6702337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:02:33+00:00 2026-05-26T07:02:33+00:00

You know Twitter is not serving its widget javascript file over https so I

  • 0

You know Twitter is not serving its widget javascript file over https so I decided to serve it through httphandler and so far, I am lost!

Here is what I have done so far :

public void ProcessRequest(HttpContext context) {

    context.Response.ContentType = "application/javascript";

    WebRequest request = WebRequest.Create("http://widgets.twimg.com/j/2/widget.js");
    request.Method = "GET";
    request.ContentType = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

    using (WebResponse response = request.GetResponse()) {

        using (Stream requestStream = response.GetResponseStream()) {

            Stream outStream = context.Response.OutputStream;
            byte[] buffer = new byte[1024];
            int len = (int)response.ContentLength, bytes;

            while (len > 0 && (bytes =
                requestStream.Read(buffer, 0, buffer.Length)) > 0) {

                outStream.Write(buffer, 0, bytes);
                len -= bytes;
            }
        }
    }
}

I am getting no error but when I debug the code, I saw that response.ContentLength is coming back as -1. What am I missing here?

UPDATE

Tried the below code as well to see if it makes any difference and didn’t work either:

public void ProcessRequest(HttpContext context) {

    context.Response.ContentType = "application/x-javascript";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://widgets.twimg.com/j/2/widget.js");
    request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    request.Method = "GET";

    using (WebResponse response = request.GetResponse()) {

        using (Stream requestStream = response.GetResponseStream()) {

            Stream outStream = context.Response.OutputStream;
            byte[] buffer = new byte[1024];
            int len = (int)response.ContentLength, bytes;

            while (len > 0 && (bytes =
                requestStream.Read(buffer, 0, buffer.Length)) > 0) {

                outStream.Write(buffer, 0, bytes);
                len -= bytes;
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:02:33+00:00Added an answer on May 26, 2026 at 7:02 am

    I solved my problem with the below code. not sure if it is the right way of doing it :

        public void ProcessRequest(HttpContext context) {
    
            context.Response.ContentType = "application/x-javascript";
    
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://widgets.twimg.com/j/2/widget.js");
            request.Accept = "application/javascript";
            request.KeepAlive = false;
            request.Method = "GET";
    
            HttpWebResponse webresponse = (HttpWebResponse)request.GetResponse();
    
            Encoding enc = System.Text.Encoding.GetEncoding(1252);
            StreamReader loResponseStream = new
              StreamReader(webresponse.GetResponseStream(), enc);
    
            string Response = loResponseStream.ReadToEnd();
    
            context.Response.Write(Response);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

https://search.twitter.com/search.json?q=doug How do I read this like VIEW SOURCE, so that I know what
Does anyone know of a Twitter service proxy in particular, or a general-purpose REST
does anyone know if there is a Twitter API library for the .Net Compact
Now that I know I can no longer communicate with Twitter mashups out there,
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
Does anyone know Twitter's rate limit on posting? Looking at their web page they
Am not sure there is a feature like , automatically update twitter tweet in
I am new to Twitter API and only know that we can pull someone's
I am writing a website that interfaces with twitter (not just to pull data,
I know iOS 5.0 has Twitter integration, but what's the fastest way to implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.